在不使用gem
命令的情况下,将已安装的gem从一个安装复制到另一个安装时,必须执行什么操作?
我必须在没有互联网连接的服务器上安装SQLite3。通常,我可以使用gem-file的副本:
gem install --local sqlite3-1.4.0.gem --platform ruby
但对于SQLite3来说,它需要连接到互联网才能获得编译一些二进制文件的库。该安装在一台有互联网连接的计算机上运行良好。
所以我的想法是让我在相同的操作系统和相同的Ruby版本上成功安装,并复制所有相关的组件,但这并不起作用。
当我打电话的时候:
require 'sequel'
db = Sequel.sqlite
我得到了这个错误:
LoadError: The specified module could not be found
d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3/sqlite3_native.so
(Sequel::AdapterNotFound)
在跟踪中是:
d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': LoadError: 126: The specified module could not be found. - d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3/sqlite3_native.so (Sequel::AdapterNotFound)
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3.rb:2:in `<top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/adapters/sqlite.rb:3:in `<top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:88:in `load_adapter'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:17:in `adapter_class'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:45:in `connect'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:121:in `connect'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:399:in `adapter_method'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:406:in `block (2 levels) in def_adapter_method'
from _ruby_version.rb:21:in `<main>'
但是文件是存在的:
我的错误是什么?
我使用的是Windows Server 2016。
我在GitHub issue中找到了一个适合我的precompiled version of SQLite3,但我想使用较新的版本。
发布于 2019-06-17 10:52:50
为此,请使用Bundler。
简而言之:
在你正在using.
gem install bundler
,当你的Gemfile改变时,列出所有的bundle install
和bundle update
来更新到最新的版本。这将生成Gemfile.lock文件。bundle exec
作为拼音执行的前缀,例如bundle exec ruby myscript
或ruby这是一个简短的总结,但请阅读有关Bundler的更多信息。它是现代Ruby部署中必不可少的一部分。
发布于 2019-06-17 11:16:15
您需要使用bundler的package
选项。
首先,您需要使用以下命令将依赖项缓存到vendor/cache
中:
bundle package --all --all-platforms
这将在本地安装Gemfile的所有依赖项,然后将目录添加到源代码存储库。
部署时,请确保使用bundle install --local
来使用本地版本。
有关详细信息,请参阅bundle package
的documentation。
https://stackoverflow.com/questions/56629180
复制相似问题