ruby on rails 打包
司马璞
2023-12-01
1. 打包Gems
有用的命令
# rake gems # List the gems that this rails application depends on
# rake gems:install # Installs all required gems for this application.
# rake gems:unpack # Unpacks all gems into vendor/gems.
# rake gems:unpack:dependencies # Unpack all dependencies
# rake gems:unpack:dependencies GEM=foo #Unpack all dependencies for gem foo
# rake gems:build # for build native extensions.
最主要还是用下面的命令,
# cd vendor/gems
# gem unpack gem-name (like sinatra)
错误 1:
config.gem: Unpacked gem yajl-ruby-0.7.6 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
解决1:
#sudo rake gems:refresh_specs
错误2:
把 sqlite3-ruby-1.2.5 卸载掉(sudo gem uninstall sqlite3-ruby),
看打包到 vendor gems 下的包能好争取运行?没有出现 “no sqlite3 的错误”
那是切出现了
NameError - uninitialized constant SQLite3::Driver::Native::Driver::API:
重新 sudo gem install sqlite3-ruby, 也没用。最后把,“vendor/gems/sqlite3-ruby.1.2.5“
删掉好了。
2. 打包 rails
我本地装rails 是2.3.5。运行#rake rails:freeze:edge后,会下载 rails.edge.zip, 然后安装到
vendor/rails/。运行后有错误:
"no such file to load - ../config/../vendor/rails/railties/lib/initializer"
看代码后,发现可能是版本不对的问题。最后从,"http://dev.rubyonrails.org/archives/"
下载 rails.2.3.5.zip 解压到vendor/rails. 成功。
3. 打包rake, rubygems
4. 用tar2rubyscript 生成,****.rb
5. 打包ruby进去
====
达到的要求是,在考虑用户没有网络连接的情况下,没有实现装任何东西包括ruby,
点击安装后就可以运行RubyOnRails 运用。
简化gem安装
[装自]http://www.javaeye.com/topic/184400
Ruby on Rails项目往往用到大量第三方的gems,在项目有新成员加入,或配置新的开发系统时,一个个的安装是件很繁琐的事情。我用的办法就是写一个自己的gem,让它依赖于项目里用到的其他gems。这样的话,安装这个gem的时候,就会顺带把其他gems安装了。
代码非常简单:
>cat install-gems.gemspec
#
#Usage:
#gem build install-gems.gemspec
#gem install install-gems.0.0.1.gem
#gem uninstall install-gems (optional, remove this useless gem)
#
spec = Gem::Specification.new do |s|
s.name = "install-gems"
s.version = "0.0.1"
s.author = "yawl"
s.email = "yawl@javaeye.com"
s.homepage = "http://xruby.javaeye.com"
s.platform = Gem::Platform::RUBY
s.summary = "This gem has no content in itself, it helps to install all the gems we depend on"
s.add_dependency('actionmailer', '>=2.0.2')
s.add_dependency('actionpack', '>=2.0.2')
s.add_dependency('activerecord', '>=2.0.2')
s.add_dependency('activeresource', '>=2.0.2')
s.add_dependency('activesupport', '>=2.0.2')
s.add_dependency('acts_as_ferret', '>=0.4.3')
s.add_dependency('capistrano', '>=2.1.0')
s.add_dependency('mysql', '>=2.7')
s.add_dependency('rails', '>=2.0.2')
s.add_dependency('rake', '>=0.8.1')
# add more here
end 阅读全文