升级到 14.04 删除了我的 ruby 1.8.7。我需要它回来。:) 糟糕。一些老项目仍然依赖它。
宝石似乎原封不动。
如何在我的计算机上保留 Ubuntu 14.04 的同时重新安装 ruby 1.8?要添加任何 PPA 吗?我尝试从源代码编译,但遇到了一堆错误。
我正在尝试使用 ruby 2.2.3 安装 json gem(我尝试过其他版本),但我总是遇到相同的错误:
Fetching: json-1.8.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/home/michell/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20160425-25421-vzm9hx.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:0:
../fbuffer/fbuffer.h: In function ‘fbuffer_to_s’:
../fbuffer/fbuffer.h:175:47: error: macro "rb_str_new" requires 2 arguments, but only 1 given
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer without a cast [enabled by default]
VALUE …Run Code Online (Sandbox Code Playgroud) 在我找到 Foreman 之前,我已经成功安装并使用了所有内容(node.js、npm、express)。我通过首先安装 Ruby 来安装 Foreman:
alex@ubuntu:~$ sudo apt-get install ruby1.9.1
Run Code Online (Sandbox Code Playgroud)
然后安装工头。我是 Unix 的新手,所以我在这里可能不必要地“sudo”,但我在终端中确认它已安装,但也有一些错误:
alex@ubuntu:~/NodeHelloWorld$ sudo gem install foreman
Invalid gemspec in [/var/lib/gems/1.8/specifications/foreman-0.26.1.gemspec]: invalid date format in specification: "2011-11-10 00:00:00.000000000Z"
Invalid gemspec in [/var/lib/gems/1.8/specifications/term-ansicolor-1.0.7.gemspec]: invalid date format in specification: "2011-10-13 00:00:00.000000000Z"
Invalid gemspec in [/var/lib/gems/1.8/specifications/foreman-0.26.1.gemspec]: invalid date format in specification: "2011-11-10 00:00:00.000000000Z"
Invalid gemspec in [/var/lib/gems/1.8/specifications/term-ansicolor-1.0.7.gemspec]: invalid date format in specification: "2011-10-13 00:00:00.000000000Z"
Successfully installed term-ansicolor-1.0.7
Successfully installed foreman-0.26.1
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试启动工头时,我得到了类似的信息:
alex@ubuntu:~/NodeHelloWorld$ foreman start
Invalid …Run Code Online (Sandbox Code Playgroud) 我在 VM 中运行 12.04,并且支持公司代理。
我已经设置了环境变量(尝试了 [http|https|ftp]_proxy 的所有小写和所有大写,以及未指定 user:pass 而是设置 http_proxy_[user|pass])
我可以通过 curl/wget 访问网络,而且我也很容易使用我的代理设置。
但是我一直无法让 gem 安装,甚至无法列出任何远程 gem。
当我尝试时,我得到以下信息:
$ sudo gem install hiera
ERROR: Could not find a valid gem 'hiera' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ECONNREFUSED: Connection refused - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
Run Code Online (Sandbox Code Playgroud)
和
$ sudo gem list -r
*** REMOTE GEMS ***
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ECONNREFUSED: Connection refused - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
Run Code Online (Sandbox Code Playgroud)
我在 StackOverflow 上做了一些搜索,并尝试了所有不需要设置 VPN 或隧道或外部程序的方法。
有什么我遗漏的,或者我有错误的环境变量吗?
更新
忘了提一下,我可以从我的主机工作站下载 gems 并以这种方式安装它们,但如果可能的话,我更希望能够直接安装。这很麻烦,尤其是当涉及很多 …
我尝试在 Ubuntu 14.04 上安装 rvm。
$ \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 184 100 184 0 0 843 0 --:--:-- --:--:-- --:--:-- 847
100 22817 100 22817 0 0 47846 0 --:--:-- --:--:-- --:--:-- 47846
Downloading https://github.com/wayneeseguin/rvm/archive/1.26.10.tar.gz
Downloading https://github.com/wayneeseguin/rvm/releases/download/1.26.10/1.26.10.tar.gz.asc
gpg: Signature made Mon 02 Feb 2015 11:09:00 AM EST using RSA key ID BF04FF17
gpg: Can't check signature: public …Run Code Online (Sandbox Code Playgroud) 我运行的是 Ubuntu 16.04。
我的ruby版本是:ruby 2.3.0p0 (2015-12-25) [x86_64-linux-gnu]
如何将 ruby 降级到 2.1 版本以与我的开发团队的其他成员保持一致(我们的一些项目依赖项与 2.3 版本不兼容)?
我已尝试https://www.brightbox.com/docs/ruby/ubuntu/#Installingthepackages上的说明:
sudo apt-get install ruby2.1
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libruby2.1' for regex 'ruby2.1'
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
Run Code Online (Sandbox Code Playgroud)
我的 Ubuntu 安装只有 2.3 版本:
ls /usr/lib/ruby/
2.3.0 gems vendor_ruby
Run Code Online (Sandbox Code Playgroud)
关于如何将 Ruby 降级到 2.1 版本还有其他想法吗?
我查看了与该主题相关的其他一些 StackExchange 问题,但无论出于何种原因,我仍然无法找到解决方案。
test.desktop这是我桌面上的简单文件:
[Desktop Entry]
Version=1.0
Name=Test
Comment=Test the terminal running a command inside it
Exec=gnome-terminal -e "~/test.rb"
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Application;
Run Code Online (Sandbox Code Playgroud)
我只是想创建一个双击时运行 Ruby 脚本的快捷方式。我试图让最终用户非常容易打开它,但当我双击该文件时,它只是在文本编辑器中不断打开。
我也验证了它也有写权限,但仍然没有。如果我替换~/test.rb为ifconfig,它仍然不起作用。
我在这里做错了什么?
我在创建新的 Rails 项目时遇到问题。当我运行时rails new project_name,它失败并出现rails webpacker:install以下错误:
LoadError: libffi.so.8: cannot open shared object file: No such file or directory - /home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/ffi-1.15.4/lib/ffi_c.so
/home/matija/Documents/learning-rails/course-project/config/application.rb:7:in `<main>'
/home/matija/Documents/learning-rails/course-project/Rakefile:4:in `<main>'
/home/matija/Documents/learning-rails/course-project/bin/rails:5:in `<top (required)>'
<internal:/home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/matija/Documents/learning-rails/course-project/bin/spring:10:in `block in <top (required)>'
<internal:kernel>:90:in `tap'
/home/matija/Documents/learning-rails/course-project/bin/spring:7:in `<top (required)>'
bin/rails:2:in `load'
bin/rails:2:in `<main>'
Caused by:
LoadError: cannot load such file -- 3.0/ffi_c
/home/matija/Documents/learning-rails/course-project/config/application.rb:7:in `<main>'
/home/matija/Documents/learning-rails/course-project/Rakefile:4:in `<main>'
/home/matija/Documents/learning-rails/course-project/bin/rails:5:in `<top (required)>'
<internal:/home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/matija/Documents/learning-rails/course-project/bin/spring:10:in `block in <top (required)>'
<internal:kernel>:90:in `tap'
/home/matija/Documents/learning-rails/course-project/bin/spring:7:in `<top (required)>'
bin/rails:2:in …Run Code Online (Sandbox Code Playgroud) 我想安装colorls。看起来很方便:
我尝试按照安装说明进行操作。然而,它们似乎不是为 Ubuntu 设计的。
首先,因为gem不存在,我不得不运行sudo apt install ruby-rubygems。
现在,当我尝试安装它时遇到此错误:
$ gem install colorls
Fetching colorls-1.4.6.gem
...
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/3.0.0 directory.
Run Code Online (Sandbox Code Playgroud)
所以我尝试使用该--user-install标志:
$ gem install --user-install colorls
WARNING: You don't have /home/flimm/.local/share/gem/ruby/3.0.0/bin in your PATH,
gem executables will not run.
Successfully installed unicode-display_width-2.4.2
Successfully installed rainbow-3.1.1
Successfully installed manpages-0.6.1
Successfully installed filesize-0.2.0
Building native extensions. This could take a while... …Run Code Online (Sandbox Code Playgroud)