Asdf: ruby: no Ruby script found in input (LoadError) when passing ruby -S

Created on 17 Jun 2016  路  6Comments  路  Source: asdf-vm/asdf

Having the same issue that https://github.com/rbenv/rbenv/issues/622 describes. I'm trying to use ruby installed from asdf with SublimeLinter rubocop

Most helpful comment

I've taken a look at this and here are my findings:

  • the error is easy to replicate with the following: ruby -S irb #=> no Ruby script found in input (LoadError)
  • from ruby --help the -S switch "look(s) for the script using PATH environment variable"
  • the PATH environment variable will start with $HOME/.asdf/bin:/$HOME/.asdf/shims
  • therefore the "script" irb it tries to invoke is the shim located in /Users/your_username/.asdf/shims
  • the script located at $HOME/.asdf/shims/irb is not a ruby script, it's a batch script -- as a shim it will call asdf-exec to execute the script against the version of ruby specified in .tool-versions
  • because it's not a ruby script (i.e. does not start with #!/usr/bin/env ruby), it results in the error no Ruby script found in input (LoadError)
  • what we really want is to execute the script, in the case irb, from the installed ruby e.g. $HOME/.asdf/installs/ruby/2.3.2/bin

I've come up with a solution that resolves the error, but unsure if this is the direction you would like to take. I've simply prepended the install_path of the desired ruby version to PATH at the end of $HOME/.asdf/plugins/ruby/bin/exec-env. This is the line I appended:

 export PATH=$install_path/bin:$PATH

The path could be prepended conditionally based on the -S switch being present. If this is acceptable solution I'm happy to create a PR for https://github.com/asdf-vm/asdf-ruby. Please let me know.

All 6 comments

@cmckni3 Thanks for reporting. I'll look into it today.

Same problem here. Any progress?

I've taken a look at this and here are my findings:

  • the error is easy to replicate with the following: ruby -S irb #=> no Ruby script found in input (LoadError)
  • from ruby --help the -S switch "look(s) for the script using PATH environment variable"
  • the PATH environment variable will start with $HOME/.asdf/bin:/$HOME/.asdf/shims
  • therefore the "script" irb it tries to invoke is the shim located in /Users/your_username/.asdf/shims
  • the script located at $HOME/.asdf/shims/irb is not a ruby script, it's a batch script -- as a shim it will call asdf-exec to execute the script against the version of ruby specified in .tool-versions
  • because it's not a ruby script (i.e. does not start with #!/usr/bin/env ruby), it results in the error no Ruby script found in input (LoadError)
  • what we really want is to execute the script, in the case irb, from the installed ruby e.g. $HOME/.asdf/installs/ruby/2.3.2/bin

I've come up with a solution that resolves the error, but unsure if this is the direction you would like to take. I've simply prepended the install_path of the desired ruby version to PATH at the end of $HOME/.asdf/plugins/ruby/bin/exec-env. This is the line I appended:

 export PATH=$install_path/bin:$PATH

The path could be prepended conditionally based on the -S switch being present. If this is acceptable solution I'm happy to create a PR for https://github.com/asdf-vm/asdf-ruby. Please let me know.

@nicholasjhenry this work for me. Thanks a lot.

Just found this issue when trying to run rake cucumber on a Rails project. Got around it meanwhile running cucumber directly without rake.

Hi,

Please can someone kindly provide an update with regards to this issue?
The workaround suggested by @nicholasjhenry works perfectly well for me but I really don't like have to hack installed files in this way.

Given this was raised around 3 months ago can I be so bold as to suggest you either accept a pull request or you close this issue.

Keep up the fantastic work though - asdf is a fantastic tool!

Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnjelinek picture johnjelinek  路  3Comments

jamesstidard picture jamesstidard  路  4Comments

ypid picture ypid  路  3Comments

Quintasan picture Quintasan  路  5Comments

niksfirefly picture niksfirefly  路  3Comments