简体   繁体   English

Capistrano软件包安装期间无效的Ruby路径'// bin / ruby​​'

[英]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. 我有一个长期运行的Rails应用程序,该应用程序可以在Ubuntu上的另一个云服务上运行,但是我正在将其迁移到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). Capistrano 3部署到现在为止,但是安装要求本地构建的gem失败,出现以下错误(这是一个示例)。

I've pasted the full error at the bottom, but the root cause error appears to be the path used to invoke ruby, 我在底部粘贴了完整的错误,但根本原因错误似乎是用于调用ruby的路径,

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

The same gem[s] install fine when installed locally on the AWS server. 如果将相同的gem本地安装在AWS服务器上,则可以很好地安装。

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, 我进行了调查,并确认通过ssh进行的部署使用的是非交互式外壳,但是我正在使用.bashrc,/ etc / environment和.bashrc这三个方法来设置ruby路径,

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. 我怀疑调用ruby的路径的形成方式存在问题,因为// bin / ruby​​(带有双正斜杠)在语法上对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. 好像应该设置一个环境变量并将其插入那些斜线之间定义为空字符串(或只是未定义),但是我已经针对交互式外壳检查了非交互式外壳的env vars,并且看起来在交互式和非交互式外壳中相同。

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). 我不使用rvm,因为我不需要,并且除非绝对需要,否则不希望增加这种复杂性(我不认为应该如此)。

Any ideas on why ruby is being invoked with that invalid path? 关于为什么使用该无效路径调用ruby的任何想法?


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. 使用Unix 34年后,我了解到“ //”是路径的有效语法,因此这是一条红色的鲱鱼。

The issue really was that ruby executable wasn't in //usr/bin 问题确实是ruby可执行文件不在// 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 最终的“修复”是从一个新的Ubuntu实例重新开始,并使用以下命令安装ruby

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. 使用apt install将ruby放在/ usr / bin目录下,一切再次变得正确。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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