Aptana Studio 3 尝试使用“rails”创建新项目。而不是“rails new”。关于轨道更新

发布于 2024-12-17 03:55:40 字数 759 浏览 2 评论 0原文

我正在使用 Aptana Studio 3,但在 IDE 中创建 Rails 项目时遇到问题。 Aptana 尝试使用命令 rails . 而不是 rails new . 创建一个新的 Rails 项目,

我在以下位置使用了解决方案:

无法使用 Aptana Studio 3 创建新的 Rails 项目

涉及安装 ruby​​,然后安装 Rails 和然后 Aptana 纠正了问题,直到我使用 gem update 更新了 Rails。这使得 Aptana 重复上述行为并且没有创建项目,尽管 rails -v 显示了预期的版本。 Aptana 控制台上显示的是 Rails 使用帮助文本。

即使在更新 Rails 版本后,有什么方法可以让 Aptana 使用正确的语法和/或 Rails 版本吗?

我显然不想再次完成整个安装,并相信我缺少一些配置设置。

仅供参考,我的配置详细信息是:

  • 操作系统:Kubuntu 11.10
  • Ruby 版本:ruby 1.9.3p0
  • Rails 版本:Rails 3.1.3
  • Aptana IDE:3.0.6

TIA

nav

I am using Aptana Studio 3 and having trouble creating a rails project in the IDE. Aptana tries to create a new rails project using the command rails . instead of rails new .

I used the solution at:

Cannot create a new Rails Project with Aptana Studio 3

involves installing ruby then rails and then Aptana which rectified problem until I updated rails using gem update. This made Aptana repeat the behaviour above and did not create the project although, rails -v shows the expected version. What was shown on the Aptana console was the rails usage help text.

Is there any way to make Aptana use the correct syntax and/or version of rails even after updating the rails version?

I obviously do no wish to go through the whole installation again and believe that there is some configuration setting I am missing.

FYI my configuration details are:

  • Operating System: Kubuntu 11.10
  • Ruby version: ruby 1.9.3p0
  • Rails version: Rails 3.1.3
  • Aptana IDE: 3.0.6

TIA

nav

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独陪着我 2024-12-24 03:55:40

这是环境变量的问题。 Aptana 入门指南提到:

您还应该确保您的登录路径设置正确
这样您就可以执行 ruby​​、gem、rails 和 git 命令
正确。在 .bashrc (或等效文件)中设置这些内容
还不够,因为在 GUI 时默认情况下不会对其进行评估
Aptana Studio 3 等应用程序已启动。

所以问题一定是 Aptana 没有看到正确的路径和/或环境变量。我有 Kubuntu 11.04 64 位和 Kubuntu 11.10 32 位,并且问题显示在使用 Aptana Studio 3.0.8 的两台计算机上。那么如何设置“登录路径”呢?

在 Ubuntu 系列以及任何使用 Linux PAM 的 Linux 发行版中,可以使用主文件夹中的 .pam_environment 文件设置会话范围的环境变量。 (KDE 还提供了设置会话环境变量的方法,但设置 .pam_environment 就足够了)。

但仅设置 PATH 环境变量是行不通的(我已经尝试过)。 您还必须设置 GEM_HOME 和 GEM_PATH

.pam_environment 文件具有非常具体的语法。我正在使用 rvm 安装 Ruby 和 Ruby on Rails。这是我的 .pam_environment 文件:

RUBY_VERSION OVERRIDE=ruby-1.9.3-p0
rvm_path DEFAULT=/home/sylvain/.rvm
rvm_bin_path DEFAULT=${rvm_path}/bin
GEM_HOME DEFAULT=${rvm_path}/gems/${RUBY_VERSION}
GEM_PATH DEFAULT=${GEM_HOME}:${GEM_HOME}@global
PATH OVERRIDE=${GEM_HOME}/bin:${GEM_HOME}@global/bin:${rvm_path}/rubies/${RUBY_VERSION}/bin:${rvm_bin_path}:${PATH}

您会注意到,即使我使用的是 rvm,这些变量也修复了 Ruby 和 gemset 的特定版本。

您必须根据您自己的环境调整这些值。请注意,我使用了 rvm 在 .bashrc 中设置的变量:RUBY_VERSION、rvm_path 和 rvm_bin_path。我可以只指定 GEM_HOME、GEM_PATH 和 PATH,但结果不会是 DRY。 ;-) 换句话说,我将不得不复制路径。请注意,我没有使用 HOME 环境变量,因为它似乎不存在于 shell 之外。

重新启动后,我尝试创建一个 Ruby on Rails 项目以及生成器(命令菜单 > Rails > 使用控制器和模型调用生成脚本),最后当我从桌面启动 Aptana Studio 3 时,它可以工作了捷径。

最后,入门指南指出:

如果以这种方式设置登录路径对您来说不切实际,
您可以通过从以下位置启动 Aptana Studio 3 来解决该问题
命令行,使用 studio3 命令行实用程序。

由于打开控制台并输入 {my_path_to_aptana_studio_3}/studio3 很麻烦,所以我首先尝试创建“/opt/aptana3/studio3”、“konsole -e /opt/aptana3/studio3”或“bash -c /”的桌面快捷方式选择/aptana3/studio3”;没有任何效果。

所以我尝试在 .bashrc 文件中添加一个别名,这样我就不必每次都从控制台输入整个内容: alias aptana="/opt/aptana3/studio3"

它也不起作用。我意识到,为了使该命令起作用,必须从 Aptana 文件夹执行。因此,以下内容有效:

alias aptana="cd /opt/aptana3 ; ./studio3"

更新:.pam_environment 解决方案不适用于 Kubuntu 11.04 64 位,因此我认为它也不适用于 Ubuntu 11.04。但是,对于 Kubuntu,可以在 ~/.kde/env 中的 shell 脚本中设置 GEM_HOME、GEM_PATH 和 PATH 的会话范围环境变量。

It's an issue with environment variables. The Aptana Getting Started Guide mentions that:

You should also make sure that your login PATH is set up correctly
such that you can execute the ruby, gem, rails, and git commands
correctly. Setting these things up in your .bashrc (or equivalent)
isn't sufficient, because it doesn't get evaluated by default when GUI
applications like Aptana Studio 3 get launched.

So the problem must be that Aptana doesn't see the right path and/or environment variables. I have Kubuntu 11.04 64-bits and Kubuntu 11.10 32-bits and the problem shows on both machines using Aptana Studio 3.0.8. How to set the "login PATH" then?

In the Ubuntu family, and any Linux distribution that uses Linux PAM, session-wide environment variables can be set with a .pam_environment file in the home folder. (KDE also offers a way to set session environment variables, but setting a .pam_environment is sufficient).

But only setting the PATH environment variable does not work (I've tried). You must also set GEM_HOME and GEM_PATH.

The .pam_environment file has a very specific syntax. I'm using rvm to install Ruby and Ruby on Rails. So here is my .pam_environment file:

RUBY_VERSION OVERRIDE=ruby-1.9.3-p0
rvm_path DEFAULT=/home/sylvain/.rvm
rvm_bin_path DEFAULT=${rvm_path}/bin
GEM_HOME DEFAULT=${rvm_path}/gems/${RUBY_VERSION}
GEM_PATH DEFAULT=${GEM_HOME}:${GEM_HOME}@global
PATH OVERRIDE=${GEM_HOME}/bin:${GEM_HOME}@global/bin:${rvm_path}/rubies/${RUBY_VERSION}/bin:${rvm_bin_path}:${PATH}

You'll note that even though I'm using rvm, these variables fix a specific version of Ruby and gemset.

You must adapt those values for your own environment. Note that I used variables that rvm sets in .bashrc: RUBY_VERSION, rvm_path and rvm_bin_path. I could have only specified GEM_HOME, GEM_PATH and PATH, but then the result wouldn't have been DRY. ;-) In other words, I would have had to duplicate paths. Note that I didn't use the HOME environment variable, because it doesn't seem to exist outside of the shell.

After rebooting, I've tried creating a Ruby on Rails project, as well as generators (Commands menu > Rails > Call Generate Script with Controller and Model) and it works, at last, when I start Aptana Studio 3 from a desktop shortcut.

And finally, the Getting Started guide states that:

If getting your login PATH set up in this way isn't practical for you,
you can work around the problem by launching Aptana Studio 3 from the
command line, using the studio3 command line utility.

Since opening a console and typing {my_path_to_aptana_studio_3}/studio3 is a hassle, I first tried making a desktop shortcut to "/opt/aptana3/studio3", "konsole -e /opt/aptana3/studio3", or "bash -c /opt/aptana3/studio3"; nothing worked.

So I tried putting an alias in my .bashrc file, so I wouldn't have to type the whole thing from a console everytime: alias aptana="/opt/aptana3/studio3"

It didn't work either. I realized that in order for the command to work, it must be executed from the Aptana folder. So the following worked:

alias aptana="cd /opt/aptana3 ; ./studio3"

UPDATE: The .pam_environment solution does not work for Kubuntu 11.04 64 bits, so I assume it would not work for Ubuntu 11.04 either. However, for Kubuntu, setting session-wide environment variables for GEM_HOME, GEM_PATH and PATH in a shell script in ~/.kde/env works.

挽袖吟 2024-12-24 03:55:40

支持之前 @SylvainC 发布我的 rbenv .pam_environment 文件的答案:

RUBY_VERSION OVERRIDE=3.0.0
rbenv_path DEFAULT=/home/@{PAM_USER}/.rbenv
GEM_HOME DEFAULT=${rbenv_path}/versions/${RUBY_VERSION}/lib/ruby/gems/${RUBY_VERSION}
GEM_PATH DEFAULT=/home/@{PAM_USER}/.local/share/gem/ruby/${RUBY_VERSION}:${GEM_HOME}
PATH OVERRIDE=${rbenv_path}/plugins/ruby-build/bin:${rbenv_path}/shims:${rbenv_path}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Supporting previous @SylvainC's answer publishing my .pam_environment file for rbenv:

RUBY_VERSION OVERRIDE=3.0.0
rbenv_path DEFAULT=/home/@{PAM_USER}/.rbenv
GEM_HOME DEFAULT=${rbenv_path}/versions/${RUBY_VERSION}/lib/ruby/gems/${RUBY_VERSION}
GEM_PATH DEFAULT=/home/@{PAM_USER}/.local/share/gem/ruby/${RUBY_VERSION}:${GEM_HOME}
PATH OVERRIDE=${rbenv_path}/plugins/ruby-build/bin:${rbenv_path}/shims:${rbenv_path}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文