如何将 运行 一个 ruby 包安装在另一个路径上?
How to run a ruby package installed on an alternative path?
我想构建并试用这个 github 项目 https://github.com/cmedley/terraforming
我已经通过 运行 中的 setup
脚本将软件包(或 gem
?抱歉,我不熟悉正确的 Ruby 术语)安装到另一个位置github 回购:
./script/setup --path ../bin
我可以看到主脚本terraforming
已经安装在bin
下。在这种情况下,路径是 bin/ruby/2.3.0/bin/terraforming
。
但是当我 运行 它时,我得到了这个错误:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:241:in
bin_path': can't find gem terraforming (>= 0.a)
(Gem::GemNotFoundException) from
../bin/ruby/2.3.0/bin/terraforming:22:in
'
从其他安装位置调用此 terraforming
脚本的正确方法是什么。
您使用的是哪种应用程序? Rails?西纳特拉?它有 gemfile
吗?如果是这样,您应该能够明确地将路径设置为 gem:
gem 'terraforming', path: '/bin/ruby/2.3.0/bin/terraforming'
对于命令行实用程序,您需要使用 $LOAD_PATH
包含 gem 的路径。您可以阅读 Ruby docs about requiring code or there are other answers on Whosebug that might be helpful like this one and this one.
您可能仍需要 gem install terraforming
来安装 gem。
script/setup
仅安装依赖项 -- 您可以在 its code that it just runs bundle install
, which installs the gems in the included gemfile 中看到。此 gem 文件不包含 terraforming
gem 本身,因为它希望您独立执行此操作。
我想构建并试用这个 github 项目 https://github.com/cmedley/terraforming
我已经通过 运行 中的 setup
脚本将软件包(或 gem
?抱歉,我不熟悉正确的 Ruby 术语)安装到另一个位置github 回购:
./script/setup --path ../bin
我可以看到主脚本terraforming
已经安装在bin
下。在这种情况下,路径是 bin/ruby/2.3.0/bin/terraforming
。
但是当我 运行 它时,我得到了这个错误:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:241:in
bin_path': can't find gem terraforming (>= 0.a) (Gem::GemNotFoundException) from ../bin/ruby/2.3.0/bin/terraforming:22:in
'
从其他安装位置调用此 terraforming
脚本的正确方法是什么。
您使用的是哪种应用程序? Rails?西纳特拉?它有 gemfile
吗?如果是这样,您应该能够明确地将路径设置为 gem:
gem 'terraforming', path: '/bin/ruby/2.3.0/bin/terraforming'
对于命令行实用程序,您需要使用 $LOAD_PATH
包含 gem 的路径。您可以阅读 Ruby docs about requiring code or there are other answers on Whosebug that might be helpful like this one and this one.
您可能仍需要 gem install terraforming
来安装 gem。
script/setup
仅安装依赖项 -- 您可以在 its code that it just runs bundle install
, which installs the gems in the included gemfile 中看到。此 gem 文件不包含 terraforming
gem 本身,因为它希望您独立执行此操作。