捆绑安装本地 pg gem 无需互联网访问
Bundle install a local pg gem without internet access
我在远程服务器上无法访问互联网。
有一个 Rails 应用程序。
尝试 bundle install
(所有 gem 都使用 bundle package --all 缓存到 app/vendor/cached
)
由于没有互联网连接,我正在使用 --local
标志(告诉 bundle
使用缓存值 - link):运行 bundle install --local
失败说:
An error occurred while installing pg (1.1.4), and Bundler cannot continue.
Make sure that "gem install pg -v '1.1.4' --source 'https://rubygems.org'" succeeds before bundling.
现在缓存 gem 位于 app/vendor/cached/pg.1.1.4.gem
的应用程序文件夹中
它只发生在 pg
gem.
通常我使用以下方法解决这个问题:bundle config build.pg --with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
(这基本上告诉 bundle 在安装 pg
时使用这些参数)。但那是我有互联网连接的时候。
现在我可以使用以下命令手动安装 pg:
gem install --local app/vendor/cached/pg.1.1.4.gem -- --with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
请注意,参数分为两部分,由 --
:
分隔
--local app/vendor/cached/pg.1.1.4.gem
--with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
所以参数的第一部分:--local app/vendor/cached/pg.1.1.4.gem
如何获取捆绑包?
在我有互联网连接的工作站上,我仍然遇到该错误,但使用它来修复它:
bundle config build.pg --with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
这基本上告诉 bundle 在安装时使用这些参数 pg
但是现在另外bundle还需要使用本地路径?我猜? (就像 gem 安装命令使用的那样?
它尝试连接到 rubygems.org
总结一下:如何使 bundle install
安装本地 pg gem
?或者将之前显示的工作 gem 安装命令转换为捆绑安装命令?
ruby 2.5.3
、rails 5.2.1
、bundler 1.17.3
bundle config
的输出:
build.pg (/home/myuser/.bundle/config): "--with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10"
我使用 bundle config build.pg
命令尝试了几种组合但没有成功:
- 捆绑配置build.pg --with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
- bundle config build.pg --local app/vendor/cached/pg.1.1.4.gem -- --with-pg-include=/usr/pgsql-10/include --with-pg-dir =/usr/pgsql-10
运行解决了
bundle config build.pg --with-pg-config=/usr/pgsql-10/bin/pg_config
.
我在远程服务器上无法访问互联网。
有一个 Rails 应用程序。
尝试 bundle install
(所有 gem 都使用 bundle package --all 缓存到 app/vendor/cached
)
由于没有互联网连接,我正在使用 --local
标志(告诉 bundle
使用缓存值 - link):运行 bundle install --local
失败说:
An error occurred while installing pg (1.1.4), and Bundler cannot continue.
Make sure that "gem install pg -v '1.1.4' --source 'https://rubygems.org'" succeeds before bundling.
现在缓存 gem 位于 app/vendor/cached/pg.1.1.4.gem
的应用程序文件夹中
它只发生在 pg
gem.
通常我使用以下方法解决这个问题:bundle config build.pg --with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
(这基本上告诉 bundle 在安装 pg
时使用这些参数)。但那是我有互联网连接的时候。
现在我可以使用以下命令手动安装 pg:
gem install --local app/vendor/cached/pg.1.1.4.gem -- --with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
请注意,参数分为两部分,由 --
:
--local app/vendor/cached/pg.1.1.4.gem
--with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
所以参数的第一部分:--local app/vendor/cached/pg.1.1.4.gem
如何获取捆绑包?
在我有互联网连接的工作站上,我仍然遇到该错误,但使用它来修复它:
bundle config build.pg --with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
这基本上告诉 bundle 在安装时使用这些参数 pg
但是现在另外bundle还需要使用本地路径?我猜? (就像 gem 安装命令使用的那样?
它尝试连接到 rubygems.org
总结一下:如何使 bundle install
安装本地 pg gem
?或者将之前显示的工作 gem 安装命令转换为捆绑安装命令?
ruby 2.5.3
、rails 5.2.1
、bundler 1.17.3
bundle config
的输出:
build.pg (/home/myuser/.bundle/config): "--with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10"
我使用 bundle config build.pg
命令尝试了几种组合但没有成功:
- 捆绑配置build.pg --with-pg-include=/usr/pgsql-10/include --with-pg-dir=/usr/pgsql-10
- bundle config build.pg --local app/vendor/cached/pg.1.1.4.gem -- --with-pg-include=/usr/pgsql-10/include --with-pg-dir =/usr/pgsql-10
运行解决了
bundle config build.pg --with-pg-config=/usr/pgsql-10/bin/pg_config
.