我运行Kubuntu,并希望安装最新的稳定Ruby版本,其编写时为2.4.2。不幸的是,Ubuntus有点落后:17.10有这个:
$ ruby --version
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]
$
我用Google搜索,看到很多建议都没有优雅。我不想使用rvm(没有任何问题 - 我只想要我的" base" ruby更新)。从源代码构建是可以的,除了它至少是默认的,在/ usr / local某处安装,并保留旧版本。我想升级到2.4.2 - 可能使用rvm来安装2.5。
我已经尝试过使用下面评论中的建议。 ppa似乎没有2.4。当我使用apt install ruby 2.4 *时,*是一个正则表达式,所以匹配2. {anything_or_nothing},所以试图拉入2.3,这不是我想要的 - 例如
$ sudo apt install ruby2.4*
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'ruby2.3' for regex 'ruby2.4*'
Note, selecting 'uwsgi-plugin-rack-ruby2.3' for regex 'ruby2.4*'
Note, selecting 'ruby2.3-dev' for regex 'ruby2.4*'
Note, selecting 'ruby2.3-doc' for regex 'ruby2.4*'
Note, selecting 'libruby2.3' for regex 'ruby2.4*'
Note, selecting 'ruby-ruby2ruby' for regex 'ruby2.4*'
Note, selecting 'ruby2.3-tcltk' for regex 'ruby2.4*'
libruby2.3 is already the newest version (2.3.3-1ubuntu1).
ruby2.3 is already the newest version (2.3.3-1ubuntu1).
ruby2.3-dev is already the newest version (2.3.3-1ubuntu1).
ruby2.3-dev set to manually installed.
The following additional packages will be installed:
libmatheval1 ruby-parser ruby-sexp-processor uwsgi-core
Suggested packages:
nginx-full | cherokee | libapache2-mod-proxy-uwsgi | libapache2-mod-uwsgi | libapache2-mod-ruwsgi uwsgi-plugins-all uwsgi-extra
The following NEW packages will be installed
libmatheval1 ruby-parser ruby-ruby2ruby ruby-sexp-processor ruby2.3-doc ruby2.3-tcltk uwsgi-core uwsgi-plugin-rack-ruby2.3
0 to upgrade, 8 to newly install, 0 to remove and 44 not to upgrade.
Need to get 4,444 kB of archives.
After this operation, 34.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
谢谢。
答案 0 :(得分:6)
如果您还没有添加我们的存储库:
$ sudo apt-add-repository ppa:brightbox / ruby-ng
$ sudo apt-get update
安装软件包:
$ sudo apt-get install ruby2.4 ruby2.4-dev
你已经开始运作了:
$ ruby2.4 -v
ruby 2.4.0p0(2016-12-24修订版57164)[x86_64-linux-gnu]
答案 1 :(得分:3)
这两种解决方案允许多个Ruby版本并排安装,并提供一个简单的方法(例如public class GenericListOfPersonsConverter : ITypeConverter<ListOfPersons, MyPersonObjectList>
{
public MyPersonObjectList Convert(ListOfPersons source, MyPersonObjectList destination, ResolutionContext context)
{
//Take 24 persons here
return new MyPersonObjectList(){MyPersonObjects = source.Persons.Take(24).Select(p => p.Name).ToList()};
}
}
public class MyPersonObjectList
{
public List<string> MyPersonObjects {get; set;}
public MyPersonObjectList() {
MyPersonObjects = new List<string>();
}
}
删除所有RVM痕迹而不会弄乱你的系统),以防万一你搞砸了。
如果您真的想要安装Ruby而不使用任何版本管理器,那么最好的选择是:rvm implode
并从源代码编译Ruby。