当我运行时
$ gem install pg
我得到以下内容
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/pg-0.15.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/pg-0.15.1/ext/gem_make.out
当我运行时
$ gem install pg -- --with-pg-config= /cygdrive/c/Program Files/PostgreSQL/9.0/bin/pg-config
我得到以下内容
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb --with-pg-config= /cygdrive/c/Program Files/PostgreSQL/9.0/bin/pg-config
Using config values from
sh: : command not found
sh: : command not found
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/pg-0.15.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/pg-0.15.1/ext/gem_make.out
“sh::命令未找到”是什么意思?
这是安装失败的原因吗?
背景:
- 我正在使用 Cygwin
- 我使用了 PostgreSQL 的一键安装程序
- pg_config.exe 文件位于 C/Program Files/PostgreSQL/9.0/bin/pg-config.exe
- libpq-fe.h 文件位于 C/Program Files/PostgreSQL/9.0/include/libpq-fe.h
最佳答案
您不能混合和匹配 native Windows 代码和 Cygwin 代码。如果你想链接到 libpq
你需要 cygwin 构建 libpq
并且你需要确保 的版本在
是 cygwin 的。来自 native Windows 构建的 PATH
中找到的 pg_configpg_config
将产生 Cygwin 工具无法理解的输出,即使它们可以,也无法成功链接到 native 库并使用它运行。
因为我不再使用 Cygwin,所以我无法就当前安装 libpq
的方式提供任何建议。大概在 Cygwin 的包管理中有一个名为 postgresql-client
、libpq
等的库
Cygwin 目前对于 PostgreSQL 来说是一个优先级很低的平台。鉴于 Ruby+Rails 和 PostgreSQL 都有原生的 Windows 版本,你在这里会遇到困难,我建议你使用这两种工具的原生版本。如果 MSVC++ 不是一个选项,您仍然可以使用 msys bash 在类 unix 的 shell 环境中工作,并且可以使用 MinGW 的 gcc 生成 native Windows 可执行文件和库。
关于ruby-on-rails-3 - 无法安装 pg gem (Rails 3 - Cygwin) - sh : : command not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17117588/