简体   繁体   中英

Invalid Ruby path '//bin/ruby' during Capistrano Bundle install

I have a long standing Rails app that runs on Ubuntu on another cloud service, but I'm migrating it to AWS.

The Capistrano 3 deployment gets so far, but it fails installing gems that require native building, with the following error (this is one example).

I've pasted the full error at the bottom, but the root cause error appears to be the path used to invoke ruby,

sh: 1: //bin/ruby: not found

The same gem[s] install fine when installed locally on the AWS server.

I've investigated, and confirmed that the deployment via ssh is using a non-interactive shell, but I'm setting the ruby path using all three of .bashrc, /etc/environment and using,

set :default_env, { "PATH" => "$PATH:/snap/bin" }

...but still no joy.

I suspect there's a problem with the way the path to invoke ruby is being formed, as //bin/ruby (with that double forward slash) is syntactically incorrect for bash shell.

It's as if there's an environment variable that should be set and inserted between those slashes is defined as an empty string (or just not defined), but I've checked env vars for non-interactive shell against the interactive shell, and all looks the same in interactive and non-interactive shells.

I'm not using rvm, as I don't need to, and would rather not add that complexity unless it's absolutely needed (and I don't think it should be).

Any ideas on why ruby is being invoked with that invalid path?


Full error details, for context and reference,

An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.21' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  mysql2


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/rails/myrailsapp/deployonaws/shared/bundle/ruby/2.3.0/gems/therubyracer-0.12.3/ext/v8
//bin/ruby -r ./siteconf20190520-13147-dgcr4x.rb extconf.rb
sh: 1: //bin/ruby: not found

extconf failed, exit code 127

OK, I figured out what was going on.

After 34 years of using Unix, I learned that '//' is valid syntax for a path, so that was a red herring.

The issue really was that ruby executable wasn't in //usr/bin

I experimented with linking from the actual path that ruby was located, but this just hit other issues with ruby versions (that old chestnut).

The eventual 'fix' was to start again with a fresh Ubuntu instance, and install ruby using

sudo apt install ruby-full

...rather than...

sudo snap install ruby --classic --channel=2.3/stable

...that I had used previously.

Using the apt install put ruby under /usr/bin, and all was right with the world again.

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM