首页 > 代码库 > 安装fpm打包工具
安装fpm打包工具
1 安装fpm打包工具
建议首次安装依次进行。后面很绕还容易把服务器搞崩溃,即使安装不上也就算了,这个打包在自己机器测试最好嘛。
1.1 首次安装
yum -y install ruby rubygems ruby-devel
gem sources-a http://mirrors.aliyun.com/rubygems/
gem sources--remove http://rubygems.org/
gem installfpm
ERROR: Could not find a valid gem ‘fpm‘ (>= 0) inany repository
可能是ruby阿里云源不稳定,添加ruby淘宝源
gem sources -a http://ruby.taobao.org/
Errorfetching http://ruby.taobao.org/:
bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
地址可能不正确,更换为https
gem sources -a https://ruby.taobao.org/
gem install fpm
ERROR: Could not find a valid gem ‘fpm‘ (>= 0) inany repository
下载出错,找不到,可能没有删除ruby阿里云源,默认找第一个添加的去了,移除
gem sources --remove
http://mirrors.aliyun.com/rubygems/
gem install fpm
Buildingnative extensions. This could take awhile...
Buildingnative extensions. This could take awhile...
ERROR: Error installing fpm:
ruby-xz requires Ruby version >=1.9.3.
ruby版本太低安装不了最新的fpm,更新ruby或安装旧版本fpm如1.4.0:
gem install fpm -v 1.4.0
Successfullyinstalled clamp-0.6.5
Successfullyinstalled fpm-1.4.0
2gems installed
Installingri documentation for clamp-0.6.5...
Installingri documentation for fpm-1.4.0...
InstallingRDoc documentation for clamp-0.6.5...
InstallingRDoc documentation for fpm-1.4.0...
1.2 快照回滚后安装(运营商网络也可能影响)
yum -y install ruby rubygems ruby-devel
gem sources -a https://ruby.taobao.org/
gem sources--remove http://rubygems.org/
gem install fpm -v 1.4.0
ERROR: Error installing fpm:
json requires Ruby version ~> 2.0.
这个问题我不知道怎么解决,考虑升级ruby了,那么不管继续执行下面安装
gem install fpm
Buildingnative extensions. This could take awhile...
Buildingnative extensions. This could take awhile...
ERROR: Error installing fpm:
ruby-xz requires Ruby version >=1.9.3.
还是报这个错误,索性研究如何把ruby1.8.7升级到1.9.3了,但是又怕其他软件比如会出问题,所以你要是怕就考虑安装到一个专门的目录吧,不要覆盖安装。
wget https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
wget http://pyyaml.org/download/libyaml/yaml-0.1.7.tar.gz
tar xf yaml-0.1.7.tar.gz
cd yaml-0.1.7
./configure
make
make install
cd ..
tar xf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
./configure
make
make install
ruby --version
ruby1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
发现还是1.8.7,怎么回事?于是查看安装成功的结尾处
installingcommand scripts: /usr/local/bin
installinglibrary scripts: /usr/local/lib/ruby/1.9.1
installingcommon headers: /usr/local/include/ruby-1.9.1
installingmanpages: /usr/local/share/man/man1
但是命令目录还是/usr/local/bin啊,和以前的一样,那么我执行ruby –version为什么是1.8.7,奇怪,难道说是没有覆盖,我去,我要把这个命令移走,重新编译
which ruby
/usr/local/bin/ruby
mv /usr/local/bin/ruby /tmp/
which ruby
/usr/bin/ruby
/usr/bin/ruby –version
ruby1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
为什么还有一个,我去,阴魂不散啊,移走
mv /usr/bin/ruby /tmp/ruby2
重新编译
make
make install
查看路径:
which ruby
查看版本
/usr/local/bin/ruby –version
ruby1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
哎,终于好了,老天有眼
那继续下一步,安装fpm,前面已经添加好了ruby淘宝源
gem install fpm
-bash:/usr/bin/gem: /usr/bin/ruby: bad interpreter: No such file or directory
这又是什么情况,说找不到ruby,我晕哦,难道gem命令内有写ruby的路径?
which gem
/usr/local/bin/gem
什么情况,gem也不在/usr/bin/gem啊,可能这是后面安装ruby就默认安装了的,那我直接来个全路径了
/usr/local/bin/gem install fpm
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constantGem::Commands::InstallCommand
我要崩溃了,难道我生下来就是看红屏的吗?说无法加载zlib
rpm -qa zlib
zlib-1.2.3-29.el6.x86_64
zlib也是有的啊,算了,进入ruby源码目录,安装源码自带的zlib
cd ext/zlib/
ruby extconf.rb
-bash:/usr/bin/ruby: No such file or directory
啥子情况哦,我又没做啥子,ruby也找不到了,忘了用全路径,可能PATH变量写在前面的是以前那个,后面那个不去使用,默认使用前面那个,但是又被移除了,所以找不到
/usr/local/bin/ruby extconf.rb
make
make: Nothing to be done for `all‘.
echo $?
0
貌似不是报错
make install
make: Nothing to be done for `install‘.
echo $?
0
貌似不是报错
再来安装,我就不信
/usr/local/bin/gem install fpm
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constantGem::Commands::InstallCommand
还是不行,难道没有make成功
cd ../../
make clean
cd ext/zlib/
/usr/local/bin/ruby extconf.rb
还是不行,哎,老子用yum死马活马医
yum install zlib-devel –y
算了还是不行,老子不搞了,煞笔玩意,这条路不可行,整到天荒地老人都咽了。
下面我又恢复快照,按首次安装进行了一次,一样很顺利
结论:还是按首次安装一步步进行吧,可能中间某个错误的步骤以及帮你安装了某些组建,跳过了所谓的
ERROR: Error installing fpm:
json requires Ruby version ~> 2.0.
不管是错误步骤还是正确步骤,都依次执行,按我说的做就可以了。绕了你们一大圈。开头有注明^V^,别怪我,自己没看清楚。
本文出自 “山大王” 博客,请务必保留此出处http://chenshifei.blog.51cto.com/11883413/1859060
安装fpm打包工具