简体   繁体   English

Ruby在Windows中离线安装gem

[英]Ruby install gem offline in Windows

I need to install some Ruby gems in Windows in the offline-mode (without internet). 我需要在Windows下以离线模式(没有Internet)安装一些Ruby gem。 I have gem files downloaded from the other PC. 我有从其他PC下载的gem文件。

As long as the gem does not require specific options (with -- ), I just execute gem install somegem --local and everything is fine. 只要gem不需要特定的选项(带有-- ),我只需执行gem install somegem --local ,一切都很好。

But if the gem does require those options, there is a trouble. 但是,如果宝石确实需要这些选项,那就麻烦了。 For example, I want to install sqlite3-1.3.10.gem : 例如,我要安装sqlite3-1.3.10.gem

gem install sqlite3 --local -- --with-sqlite3-dir="c:\programs\sqlite"

This returns me an error: 这返回一个错误:

ERROR:  While executing gem ... (OptionParser::InvalidOption)
invalid option: --with-sqlite3-dir=c:\programs\sqlite

What is wrong? 怎么了?

  • ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32] 红宝石2.2.2p95(2015-04-13修订版50295)[x64-mingw32]
  • Rails 4.2.2 导轨4.2.2

Got the reason. 有原因。 I ran all commands in Windows PowerShell . 我在Windows PowerShell运行了所有命令。

Now I tried to do it in usual cmd.exe - and it just worked. 现在,我尝试在通常的cmd.exe执行此操作-并且它正常工作。

Just for a case here is how I installed sqlite3.gem : followed instructions from https://stackoverflow.com/a/16023062 and executed command: 只是一个例子,这是我如何安装sqlite3.gem :按照https://stackoverflow.com/a/16023062的说明进行操作并执行命令:

gem install sqlite3-1.3.10.gem --local --platform=ruby -- '--with-sqlite3-dir="c:/programs/sqlite" --with-sqlite3-lib="c:/programs/sqlite/.libs" --with-sqlite3-include="c:/programs/sqlite"'

Thank you for comments, they helped to correct the command. 感谢您的评论,他们帮助纠正了该命令。

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

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