gpt4 book ai didi

ruby - 如何部署 Rails 应用程序并在用户目录中安装 Ruby Native Extension

转载 作者:太空宇宙 更新时间:2023-11-03 16:32:06 27 4
gpt4 key购买 nike

有谁知道部署到服务器并将 native 扩展安装在用户目录中的方法吗?

我正在使用 capistrano 和 bundler,并且没有对/usr/local 的写入权限... 带有 native 扩展(在当前情况下为 bcrypt-ruby)的 Gems 不会安装。我最初的问题是无法找到“config.h”。

在对生成的 Makefile 的一些调查中,这一行是罪魁祸首:

 $(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h

Mkmf 以这种方式定义 arch_hdrdir:

arch_hdrdir = $(extout)/include/$(arch)

为什么这样做有点令人费解。不幸的是,$extout 是“”,因此,Make 在/include/i686-linux/ruby/config.h 中寻找配置但失败了。

对 mkmf 的进一步调查使我认为 $extout 被设置为在 install_dirs 中评估为 true 的东西,但最终在 makefile 中成为一个空字符串。但是,我不知道它在哪里设置。

为了改变现状,我尝试在 extconf.rb 中设置 $extout。但是……

1) 如果我将它设置为“/usr/local/lib/ruby”,makefile 会尝试将 .so 安装到/usr/local/lib/ruby... 我没有写入权限的地方。嘘。

2) 我尝试将 $extout 设置为“/home/crivens/railsapp/shared/bundle”。这实际上编译了,但是应用程序找不到 .so 文件。而且我必须做很多技巧才能到达那里。

在这上面花了很多时间之后,我正在寻找建议!

  1. 是否可以在不访问系统存储库的情况下安装带有 native 扩展的 gem?
  2. 这样做的最佳策略是什么?
  3. mkmf 是否有任何记录? (我肯定找不到太多的笔记)
  4. $extout 有什么用,它是如何设置的?

提前致谢。

最佳答案

我认为您正在寻找的是 ruby​​ 版本管理器 (rvm)。它在此处可用,可让您管理 Ruby、Rails 和 Gem 集的版本。

https://rvm.io/

这里还有一个很好的入门指南:http://rvm.beginrescueend.com/rvm/install/

安装过程如下:

[sam@mungr ~]$ \curl -L https://get.rvm.io | bash -s stable --ruby
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10956 100 10956 0 0 2240 0 0:00:04 0:00:04 --:--:-- 2240
Please read and follow further instructions.
Press ENTER to continue.
Downloading RVM from wayneeseguin branch stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1243k 100 1243k 0 0 570k 0 0:00:02 0:00:02 --:--:-- 929k

Installing RVM to /home/sam/.rvm/
Adding rvm PATH line to /home/sam/.bashrc /home/sam/.zshrc.
Adding rvm loading line to /home/sam/.bash_profile /home/sam/.zprofile.

# RVM: Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm/
# Screencast: http://screencasts.org/episodes/how-to-use-rvm

# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'

Installation of RVM in /home/sam/.rvm/ is almost complete:

* To start using RVM you need to run `source /home/sam/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.

# sam,
#
# Thank you for using RVM!
# I sincerely hope that RVM helps to make your life easier and
# more enjoyable!!!
#
# ~Wayne


rvm 1.17.7 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

No binary rubies available for: downloads/ruby-1.9.3-p362.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Fetching yaml-0.1.4.tar.gz to /home/sam/.rvm/archives
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 460k 100 460k 0 0 342k 0 0:00:01 0:00:01 --:--:-- 492k
Extracting yaml to /home/sam/.rvm/src/yaml-0.1.4
Configuring yaml in /home/sam/.rvm/src/yaml-0.1.4.
Compiling yaml in /home/sam/.rvm/src/yaml-0.1.4.
Installing yaml to /home/sam/.rvm/usr
Installing Ruby from source to: /home/sam/.rvm/rubies/ruby-1.9.3-p362, this may take a while depending on your cpu(s)...
ruby-1.9.3-p362 - #downloading ruby-1.9.3-p362, this may take a while depending on your connection...
ruby-1.9.3-p362 - #extracting ruby-1.9.3-p362 to /home/sam/.rvm/src/ruby-1.9.3-p362
ruby-1.9.3-p362 - #extracted to /home/sam/.rvm/src/ruby-1.9.3-p362
ruby-1.9.3-p362 - #configuring
ruby-1.9.3-p362 - #compiling
ruby-1.9.3-p362 - #installing
Retrieving rubygems-1.8.24
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 371k 100 371k 0 0 430k 0 --:--:-- --:--:-- --:--:-- 611k
Extracting rubygems-1.8.24 ...
Removing old Rubygems files...
Installing rubygems-1.8.24 for ruby-1.9.3-p362 ...
Installation of rubygems completed successfully.
Saving wrappers to '/home/sam/.rvm/bin'.
ruby-1.9.3-p362 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.3-p362 - #importing default gemsets (/home/sam/.rvm/gemsets/), this may take time ...
Install of ruby-1.9.3-p362 - #complete
Creating alias default for ruby-1.9.3-p362.
Recording alias default for ruby-1.9.3-p362.
Creating default links/files
Saving wrappers to '/home/sam/.rvm/bin'.

* To start using RVM you need to run `source /home/sam/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.

一旦完成,我就得到了 Ruby 1.9.3-p362 的全功能安装:

[sam@mungr ~]$ source /home/sam/.rvm/scripts/rvm
[sam@mungr ~]$ rvm list

rvm rubies

=* ruby-1.9.3-p362 [ x86_64 ]

# => - current
# =* - current && default
# * - default

哪个版本的 Ruby?

[sam@mungr ~]$ which ruby
~/.rvm/rubies/ruby-1.9.3-p362/bin/ruby

一点Hello World

[sam@mungr ~]$ ruby -e "puts 'Hello world'"
Hello world

编辑 #1

作者在讨论这个问题的过程中,Crivens ,注意到他收到以下错误:

Error curl: (77) Problem with the SSL CA cert (path? access rights?) and OS is Linux version 2.6.32-042stab055.16 (root@rh6-build-x64) (gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC) ) #1 SMP Fri Jun 8 19:22:28 MSD 2012. I'm still hoping to use the system install of ruby.

如果您遇到此错误,通常意味着以下两种情况之一:

1. 我认为您只是缺少这个 RPM,ca-certificates-2010.63-3.el6。这些是证书。 My install of RVM on a Ubuntu 8.04.4 machine fails. Should I install it as multi-user instead?

解决方案 #1

% yum install ca-certificates-2010.63-3.el6

2. rvm 的开发人员 Wayne 将 URL 从 rvm.beginrescueend.com 更改为 rvm.io,并且可能对 SSL 证书产生了兴趣。 Curl Certificate Error when Using RVM to install Ruby 1.9.2

解决方案 #2

% curl -L get.rvm.io | bash -s stable

-or-

% echo insecure > ~/.curlrc

关于ruby - 如何部署 Rails 应用程序并在用户目录中安装 Ruby Native Extension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14188561/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com