GithubHelp home page GithubHelp logo

asdf-community / asdf-crystal Goto Github PK

View Code? Open in Web Editor NEW
73.0 7.0 16.0 42 KB

Crystal plugin for the asdf version manager

Home Page: https://github.com/asdf-vm/asdf

License: Apache License 2.0

Shell 100.00%
asdf asdf-plugin

asdf-crystal's Introduction

asdf-crystal

Crystal plugin for asdf version manager

GitHub Workflow Status All Contributors PRs Welcome License

Installation

asdf plugin-add crystal https://github.com/asdf-community/asdf-crystal.git

Usage

Check asdf readme for instructions on how to install & manage versions.

Useful information

asdf uses the .tool-versions for auto-switching between software versions. To ease migration, you can have it read .crystal-version file to find out what version of Crystal should be used. This only works with the exact version. To do this, add the following to ~/.asdfrc:

legacy_version_file = yes

Contributors ✨

Thanks goes to these wonderful people (emoji key):


marciogm

💻 📖 🚧

BSKY

💻 📖 🚧 🚇

Stanislav Lapata

💻

Jeff Hertzler

💻

Eloy Pérez

💻

Chet Bortz

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Licensed under the Apache License, Version 2.0.

asdf-crystal's People

Contributors

allcontributors[bot] avatar cbortz avatar dependabot[bot] avatar epergo avatar github-actions[bot] avatar hovsater avatar jeffhertzler avatar jwaldrip avatar marciogm avatar nzws avatar smorimoto avatar stanislav-lapata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

asdf-crystal's Issues

Crystal 0.24.1 file doesn't match tag_name

Version 0.24.1 has tag_name: "v0.24.1" and downloads as crystal-v0.24.1-version.tar.gz but the install file expects a file named crystal-v0.24.1-version.tar.gz causing 'Error opening archive' errors.

mac arm64, asdf from homebrew, "crystal play" can't find libssl

crystal play                                                   
Listening on http://127.0.0.1:8080
ld: library not found for -lssl (this usually means you need to install the development package for libssl)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc "${@}" -o /Users/megatux/.cache/crystal/crystal-run-play-1-1.tmp  -rdynamic -L/Users/megatux/.asdf/installs/crystal/1.5.1/embedded/lib -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lpcre -lgc -L/opt/homebrew/Cellar/libevent/2.1.12/lib -levent -liconv`

I only tried setting the LIBRARY_PATH variable like this export LIBRARY_PATH=/opt/homebrew/Cellar/[email protected]/1.1.1q/lib but it fails:

crystal play                                                   
Listening on http://127.0.0.1:8080
Undefined symbols for architecture arm64:
  "_ERR_load_crypto_strings", referenced from:
      ___crystal_main in _main.o
  "_OPENSSL_add_all_algorithms_noconf", referenced from:
      ___crystal_main in _main.o
  "_SSL_library_init", referenced from:
      ___crystal_main in _main.o
  "_SSL_load_error_strings", referenced from:
      ___crystal_main in _main.o
  "_SSLv23_method", referenced from:
      _*OpenSSL::SSL::Context::default_method:Pointer(Void) in O-penS-S-L-5858S-S-L-5858C-ontext.o
  "_sk_free", referenced from:
      _~procProc(Pointer(Void), Nil)@/Users/megatux/.asdf/installs/crystal/1.5.1/src/openssl/ssl/hostname_validation.cr:71 in _main.o
      _~proc2Proc(Pointer(Void), Nil)@/Users/megatux/.asdf/installs/crystal/1.5.1/src/openssl/ssl/hostname_validation.cr:71 in _main.o
      _~proc3Proc(Pointer(Void), Nil)@/Users/megatux/.asdf/installs/crystal/1.5.1/src/openssl/ssl/hostname_validation.cr:71 in _main.o
      _~proc4Proc(Pointer(Void), Nil)@/Users/megatux/.asdf/installs/crystal/1.5.1/src/openssl/ssl/hostname_validation.cr:71 in _main.o
      _~proc5Proc(Pointer(Void), Nil)@/Users/megatux/.asdf/installs/crystal/1.5.1/src/openssl/ssl/hostname_validation.cr:71 in _main.o
      _~proc6Proc(Pointer(Void), Nil)@/Users/megatux/.asdf/installs/crystal/1.5.1/src/openssl/ssl/hostname_validation.cr:71 in _main.o
  "_sk_num", referenced from:
      _*OpenSSL::SSL::HostnameValidation::matches_subject_alternative_name<String, Pointer(Void)>:OpenSSL::SSL::HostnameValidation::Result in O-penS-S-L-5858S-S-L-5858H-ostnameV-alidation.o
  "_sk_pop_free", referenced from:
      _*OpenSSL::SSL::HostnameValidation::matches_subject_alternative_name<String, Pointer(Void)>:OpenSSL::SSL::HostnameValidation::Result in O-penS-S-L-5858S-S-L-5858H-ostnameV-alidation.o
  "_sk_value", referenced from:
      _*OpenSSL::SSL::HostnameValidation::matches_subject_alternative_name<String, Pointer(Void)>:OpenSSL::SSL::HostnameValidation::Result in O-penS-S-L-5858S-S-L-5858H-ostnameV-alidation.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc "${@}" -o /Users/megatux/.cache/crystal/crystal-run-play-1-1.tmp  -rdynamic -L/Users/megatux/.asdf/installs/crystal/1.5.1/embedded/lib -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lpcre -lgc -L/opt/homebrew/Cellar/libevent/2.1.12/lib -levent -liconv`

Doesn't work on M1 Mac

% uname -a
Darwin Phuong-Mac-M1-Pro.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64
% asdf list crystal
No versions installed
% asdf install crystal 1.1.0
\e[31mFail:\e[m Unsupported architecture

PCRE-Lib is missing on Ubuntu

I am running Ubuntu 18.04 and installed crystal 0.33.0 via asdf. I seemingly installed fine, crystal --help ran fine. However, compiling a crystal-file led to complaints about "libpcre" missing.

I removed the asdf-installed version and installed the official/upstream package. This works as advertised. I would like to switch to an asdf-managed version, but am currently blocked.

There may be other depdencies missing, which were shadowed by this error.

PKG_CONFIG_PATH issue on osx

I seem to be running into precisely this issue:
crystal-lang/crystal#6875

I followed the fix instructions there and they didn't help with my asdf-installed crystal.

I asdf plugin-remove crystal and followed the same instructions using homebrew instead and things work fine. So it seems the asdf plugin needs to address this same issue in a similar manner to the way that the homebrew group did.

v0.34.0 unable to run amber specs on macOS Catalina

Hey y'all! Reporting an issue that I'm having when trying to run the Amber framework specs on my local machine.

I'm asking in this repository rather than in the amber repository because when I install v0.34.0 via homebrew, I am able to run the specs just fine. When I run the specs with v0.34.0 installed via asdf, I get the following error:

Assertion failed: (Idx < NumElements && "Invalid element idx!"),
  function getElementOffset,
  file /var/cache/omnibus/src/llvm/llvm-6.0.1.src/include/llvm/IR/DataLayout.h,
  line 514.
/Users/me/.asdf/installs/crystal/0.34.0/bin/crystal:
  line 103: 46649 Abort trap: 6 
  "$INSTALL_DIR/embedded/bin/crystal" "$@"

To reproduce this, the command I am running is:

crystal spec ./spec/amber --debug --verbose

Please let me know if I can provide any additional information. If any of y'all could point me in the right direction, it would be greatly appreciated!

Don't work on OS X

On OS X

$ asdf install crystal 0.20.5
dyld: Library not loaded: /usr/local/opt/libevent/lib/libevent-2.0.5.dylib
  Referenced from: /Users/fazibear/.asdf/installs/crystal/0.20.5/embedded/bin/crystal
  Reason: image not found
/Users/fazibear/.asdf/installs/crystal/0.20.5/bin/crystal: line 102: 79582 Trace/BPT trap: 5       "$INSTALL_DIR/embedded/bin/crystal" "$@"

same with

$ asdf install crystal ref:0.20.5

v0.23.1 install broken on OS X

0.23.1 won't install on OSX - I'm using 0.23.0 as a workaround (this works).
See printscreen attached.

I can reproduce, let me know if you need anything else.

image

Read version from shard.yml

It would be great if asdf could read the crystal version required for a project from the shard.yml file.
This would avoid the risk of the version numbers specified in shard.yml and .tool-verions to mismatch.

It could be implemented similar to how asdf-ruby reads the version from Gemfile.

Installation not working

It seems that grep regex for release url is outdated.

On MacOS:

~ [] $ asdf install crystal 2.7.0                                                                                                                                                                                                            
/var/folders/74/wgszrq451z97qh_hl3xl_mk80000gn/T//crystal-2.7.0-version.tar.gz
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
tar: Error opening archive: Failed to open '/var/folders/74/wgszrq451z97qh_hl3xl_mk80000gn/T//crystal-2.7.0-version.tar.gz'

I tried to play with a source and found out that get_download_url returns nothing. Ultimately decided to install it via homebrew.

Add support for Crystal 1.2

Crystal 1.2 was released on October 13th.

asdf install crystal latest
∗ Downloading and installing Crystal...
\e[31mFail:\e[m Could not download Crystal 1.2.0
\e[31mFail:\e[m An error occurred

Crystal does not work on Fedora

OS: Fedora 26
Crystal version: 0.24.2

Problem description

I can’t run crystal:

# hello.cr
puts "Hello, world!"
$ crystal hello.cr
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
/usr/bin/ld: cannot find -levent
/usr/bin/ld: skipping incompatible /usr/lib/librt.so when searching for -lrt
/usr/bin/ld: skipping incompatible /usr/lib/libdl.so when searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/***/.cache/crystal/crystal-run-hello.tmp'  -rdynamic  -lpcre -lgc -lpthread /home/***/.asdf/installs/crystal/0.24.2/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`

Expectet behaviour

Crystal should run on Fedora.

Ideas

This seems to be a library incompatibility between the system crystal was built on and my distribution. I see two ways to avoid this:

  • provide statically-linked binaries
  • check for the distribution and build crystal from sources if necessary

Edit : After reading more about crystal, it seems my two points can’t change anything. The crystal binary itself works, but it can’t link correctly my program. Building crystal from sources is not possible since crystal requires crystal to build.

Weird problem with asdf-crystal's 0.23.1 on macOS 10.12

Hello.

I'm trying out this new web framework, and I installed 0.23.1 using asdf-crystal. When I run lucky init <name> it all seems to work, but then when I go the created dir and run lucky dev, I see this:

...
16:16:27 web.1      |  [warn] kq_init: detected broken kqueue; not using.: Undefined error: 0
16:16:28 web.1      |  Error in tasks.cr:2: while requiring "./src/app"
16:16:28 web.1      |  require "./src/app"
16:16:28 web.1      |  ^
16:16:28 web.1      |  in src/app.cr:1: while requiring "./dependencies"
16:16:28 web.1      |  require "./dependencies"
16:16:28 web.1      |  ^
16:16:28 web.1      |  in src/dependencies.cr:1: while requiring "lucky_record": can't find file 'lucky_record' relative to '/Users/bruno/Code/WORK/constable-crystal/src'
16:16:28 web.1      |  require "lucky_record"
16:16:28 web.1      |  ^
16:16:28 web.1      Exited Successfully
...

But if I run this with Crystal 0.23.1 from homebrew, it works fine:

[WARN] No ENV file found
16:17:35 assets.1   |  yarn run v1.0.1
16:17:35 assets.1   |  warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
16:17:35 assets.1   |  $ "/Users/bruno/Code/WORK/constable-crystal/node_modules/.bin/brunch" "watch"
16:17:37 web.1      |  Beginnning to watch your project
16:17:37 web.1      |  compiling...
16:17:38 assets.1   |  16:17:38 - info: compiled 6 files into 2 files in 2.0 sec
16:17:39 web.1      |  Listening on http://127.0.0.1:8080...
16:17:39 web.1      |  yarn run v1.0.1
16:17:40 web.1      |  warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
16:17:40 web.1      |  $ "/Users/bruno/Code/WORK/constable-crystal/node_modules/.bin/browser-sync" "start" "-c" "bs-config.js"
16:17:40 web.1      |  [Browsersync] Proxying: http://localhost:8080
16:17:40 web.1      |  [Browsersync] Access URLs:
16:17:40 web.1      |   ------------------------------------
16:17:40 web.1      |         Local: http://localhost:3000
16:17:40 web.1      |      External: http://10.2.21.156:3000
16:17:40 web.1      |   ------------------------------------
16:17:40 web.1      |            UI: http://localhost:3001
16:17:40 web.1      |   UI External: http://10.2.21.156:3001
16:17:40 web.1      |   ------------------------------------
16:17:40 web.1      |  [Browsersync] Watching files...
16:17:41 web.1      |  GET /favicon.ico? - 404 (230.0µs)
16:17:41 web.1      |  GET /? - 200 (4.42ms)
16:17:41 web.1      |  GET /favicon.ico? - 404 (33.0µs)
16:17:41 web.1      |  GET /favicon.ico? - 404 (34.0µs)
16:17:41 web.1      |  GET /favicon.ico? - 404 (48.0µs)
16:17:41 web.1      |  GET /favicon.ico? - 404 (42.0µs)
16:17:41 web.1      |  GET /favicon.ico? - 404 (44.0µs)
16:17:42 web.1      |  GET /favicon.ico? - 404 (47.0µs)
16:17:42 web.1      |  GET /favicon.ico? - 404 (36.0µs)

I have no idea why this would be the case. Here are the -v outputs for both versions:

  • homebrew:
    Crystal 0.23.1 (2017-09-08) LLVM 4.0.1
  • asdf-crystal:
    [warn] kq_init: detected broken kqueue; not using.: Undefined error: 0 Crystal 0.23.1 [e2a1389] (2017-07-13) LLVM 3.8.1

Is this a compilation flag issue for asdf-crystal's builds?

Thanks for any help!

Shim for `pcregrep` shadows system binary

I have a system install of PCRE tools that includes the pcregrep binary. When I installed the asdf-crystal plugin, suddenly I couldn't run pcregrep anymore, with this error:

asdf: No version set for command pcregrep
you might want to add one of the following in your .tool-versions file:

crystal 0.35.1

It seems that the shims for a plugin always exist in the PATH even if no version of the language is active, shadowing any system binaries of the same name.

I'm not sure why a plugin for Crystal should necessarily provide a pcregrep binary; I searched the code in this repo but there were no results. Maybe the language distribution itself happens to include a pcregrep, and the plugin is just adding shims for every binary rather than choosing a specific subset?

CI build is failing, missing Authorization token

Currently the CI build is failing because list-all does not send an Authorization token on the request to github.
Running the ci command locally gives the following error output:

$ asdf plugin-test crystal https://github.com/marciogm/asdf-crystal.git 'crystal -v'
Cloning into '/tmp/asdf.VWjZ'...
done.
Note: checking out '1886e00cf18f5e9d3c5ac1bd18426d04121d4472'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

Cloning into '/tmp/asdf.VWjZ/plugins/crystal'...
remote: Enumerating objects: 59, done.
remote: Total 59 (delta 0), reused 0 (delta 0), pack-reused 59
Unpacking objects: 100% (59/59), done.

Looks like crystal/bin/list-all relies on GitHub releases
but it does not properly sets an Authorization header to prevent
GitHub API rate limiting.

See https://github.com/asdf-vm/asdf/blob/master/docs/creating-plugins.md#github-api-rate-limiting
FAILED: crystal/bin/list-all does not set GitHub Authorization token

Unknown or unavailable versions may erroneously "succeed" when attempting to install

Hey y'all. Quick background: I'm using macOS with ohmyzsh. I was messing around with the plugin today and I tried to install a version that I knew wouldn't be available to see what would happen. I was surprised to see that asdf reported that the version was successfully installed even though the output suggested otherwise:

> $ asdf install crystal 0.42.0
∗ Downloading and installing Crystal...
tar: Error opening archive: Unrecognized archive format
The installation was successful!

I can also see the version when listing installations:

> $ asdf list crystal
  0.30.0
  0.31.0
  0.32.0
  0.33.0
  0.34.0
  0.42.0

I've verified that removing this failed installation is as simple as using asdf uninstall. Although possibly trivial, I don't think this behavior is expected. I am going to open a pull request addressing there here in a few minutes.

Compiling a crytsal for interpreter

I have no idea if this is the right repo for this bug report, or if it should go at https://github.com/crystal-lang/distribution-scripts Perhaps someone here can pull back the curtain enough for me to either solve the problem or at least find the right place to go for better help.

I'm on an M* mac, and I'm curious to try out the interpreter. So I pulled down the repo and make interpreter=1 to spin it off.

It fails, and this is the error message it emits:

ld: warning: ignoring file /Users/robert/.asdf/installs/crystal/1.6.2/embedded/lib/libffi.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Crystal is using the currently available crystal to compile itself -- the currently available crystal was installed with asdf-crystal, and it seems like the bundled libffi.a file is the wrong architecture for the M-series arm chip. What should my next step be?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.