注释命令不起作用,将其添加到我的 gemfile 中

发布于 2024-09-24 01:43:16 字数 566 浏览 2 评论 0原文

我的 gem 文件如下所示:

 group :development, :test do
    gem 'rspec-rails'
    gem 'annotate-models', '1.0.4'
 end

我运行了“bundle install”并安装了 annotate-models 包。

如果我输入:annotate,我会收到命令未找到错误。

如果我输入:bundle show annotate,我会收到“在当前包中找不到 gem 注释”的信息。

如果我输入bundle show annotate-models,它会说它安装在:

/Library/Ruby/Gems/1.8/gems/annotate-models-1.0.4

输入:

annotate-models

也不起作用。

我正在跟踪railstutorial.org并在这一点上陷入困​​境。

My gem file looks like:

 group :development, :test do
    gem 'rspec-rails'
    gem 'annotate-models', '1.0.4'
 end

I ran 'bundle install' and it installed the annotate-models bundle.

If I type: annotate I get a command not found error.

If I type: bundle show annotate I get a 'could not find gem annotate in the current bundle.

If I type bundle show annotate-models it says it installed in:

/Library/Ruby/Gems/1.8/gems/annotate-models-1.0.4

typing:

annotate-models

doesn't work either.

I'm following along in railstutorial.org and got stuck at this point.

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

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

发布评论

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

评论(9

戈亓 2024-10-01 01:43:16

编辑:更好的版本(使用 Bundler 仅为当前项目安装它)

  1. gem 'annotate' 添加到 Gemfile
  2. Run $ bundle install
  3. Run $ bundle exec annotate< /code>

Edit2:似乎您现在必须显式指定注释版本,因此在 Gemfile 中放入 gem 'annotate', '2.4.1.beta1' (这是一个预发布的 beta gem,可与最新版本的 activerecord 而不是直接指定 github 存储库)

Edit3:2.5.0 Final 现已发布,所以希望不再需要强制使用 beta 版本,只需获取最新版本就可以了!

旧版本(也在系统级别安装 gem):

如果运行 Rails 3,则练习是:

  1. 运行 $ sudo gem install annotate
  2. gem 'annotate' 添加到 Gemfile
  3. Run $bundle install
  4. 运行 $annotate
  5. 开心点:)

Edit: Better version (using Bundler to install it only for the current project)

  1. Add gem 'annotate' to Gemfile
  2. Run $ bundle install
  3. Run $ bundle exec annotate

Edit2: Seems you have to explicitly specify annotate version for now, so in Gemfile put gem 'annotate', '2.4.1.beta1' (which is a prereleased beta gem that works with the latest version of activerecord as opposed to specifying the github repo directly)

Edit3: 2.5.0 final is out now, so hopefully no need to force a beta version any more, just getting the latest should work!

Old version (with installing the gem on a system level too):

If running Rails 3 the drill is:

  1. Run $ sudo gem install annotate
  2. Add gem 'annotate' to Gemfile
  3. Run $ bundle install
  4. Run $ annotate
  5. Be happy :)
酒废 2024-10-01 01:43:16

您应该在捆绑环境中运行该命令:

$ bundle exec annotate

查看 手册页更多细节。

You should run the command inside your bundled environment with:

$ bundle exec annotate

Check out the man page for more details.

把昨日还给我 2024-10-01 01:43:16

投票最多的答案并不完全适合我,因为在遵循建议的解决方案时,我遇到了额外的错误:

undefined method `namespace' for main:Object (NoMethodError)

我在下面包含了对我有用的内容(我在 Ubuntu 下使用 Ruby 1.9.2 和 Rails 3.1.3 11.10):

  1. 安装注释

    $ gem install 注释
    
  2. 修改 Gemfile 添加以下行

    gem '注释', 
        :git => 'git://github.com/jeremyolliver/annotate_models.git', 
        :分支=> 'rake_兼容性'
    
  3. 安装包

    $ 捆绑安装    
    
  4. 现在您可以按如下方式使用注释:

    $bundle exec 注释
    

The most voted answer didn't fully work for me, as I was getting and additional error when follow the proposed solution:

undefined method `namespace' for main:Object (NoMethodError)

I'm including below what worked for me (I'm using Ruby 1.9.2 and Rails 3.1.3 under Ubuntu 11.10):

  1. Install annotate

    $ gem install annotate
    
  2. Modify Gemfile adding the following line

    gem 'annotate', 
        :git => 'git://github.com/jeremyolliver/annotate_models.git', 
        :branch => 'rake_compatibility'
    
  3. Install bundle

    $ bundle install    
    
  4. Now you can use annotate as follows:

    $ bundle exec annotate
    
浮生面具三千个 2024-10-01 01:43:16

我对此很陌生,但我在执行 Rails 教程时遇到了这个问题,但通过将 gems bin 路径添加到 PATH 环境变量,我能够修复它。 (就像 gertas 上面说的几篇文章一样)

首先在命令提示符中:

gem list -d annotate

你会得到一个类似的结果

:注释模型(1.0.4)

作者:戴夫·托马斯

Rubyforge: http://rubyforge.org/projects/annotate-models

< p>
主页:h'ttp://annotate-models.rubyforge.org

安装在:C:/ruby192/lib/ruby/gems/1.9.1

关键行是:

安装在:C:/ruby192/lib/ruby/gems/1.9.1

所以在这种情况下将 /bin 添加到该路径,例如我使用: C:\ruby192\lib\ruby\gems\1.9.1\bin 是你要添加到 PATH 环境变量中的内容。

要在 Vista 上更改 PATH 环境变量,请转至:控制面板 >>系统>>高级系统设置(左侧链接)。该框打开后,单击“高级”选项卡,然后单击“环境变量”按钮。然后在系统变量中找到 PATH 变量并单击编辑按钮。由于路径是用分号分隔的,所以添加

;C:\ruby192\lib\ruby\gems\1.9.1\bin

在变量值字段的末尾。

它应该看起来像
`一些/路径;some_other_path;C:\ruby192\lib\ruby\gems\1.9.1\bin`
完成后

保存,然后关闭并重新打开命令提示符。此后,annotate 和 rspec 开始为我工作。祝你好运。

I'm new to this, but I was having this problem doing the rails tutorial, but by adding the gems bin path to the PATH env variable I was able to fix it. (Just like gertas said a few posts above)

First in the command prompt:

gem list -d annotate

and you'll get a result that says something like

: annotate-models (1.0.4)

Author: Dave Thomas

Rubyforge: http://rubyforge.org/projects/annotate-models

Homepage: h'ttp://annotate-models.rubyforge.org

Installed at: C:/ruby192/lib/ruby/gems/1.9.1

the key line is:

Installed at: C:/ruby192/lib/ruby/gems/1.9.1

So in this case add a /bin to that path, For example I used: C:\ruby192\lib\ruby\gems\1.9.1\bin is what you want to add to your PATH environment variable.

To change your PATH environment variable on Vista do the following go to: control panel >> system >> advanced system settings(link on the left). Once the box opens up,click the Advanced tab and then the Environment variables button. Then on the system variables find the PATH variable and click the Edit button. Since paths are separated by semi-colons, add

;C:\ruby192\lib\ruby\gems\1.9.1\bin

At the end of the variable value field.

It should look like
`some/path;some_other_path;C:\ruby192\lib\ruby\gems\1.9.1\bin`
when you finish

Save it, and close and reopen the command prompt. annotate and rspec started to work for me after that. Good luck.

聽兲甴掵 2024-10-01 01:43:16

使用

gem 'annotate', '2.4.0'

代替

gem 'annotate-models', '1.0.4'

RubyGems.org 上的 gem 名称似乎已更改。

Use

gem 'annotate', '2.4.0'

instead of

gem 'annotate-models', '1.0.4'

It looks like the gem name was changed at RubyGems.org.

悟红尘 2024-10-01 01:43:16

我认为您的 PATH 环境变量缺少 gems bin 目录的路径。
我想应该是:/Library/Ruby/Gems/1.8/bin

I think your PATH env variable lacks path to gems bin directory.
I guess it should be: /Library/Ruby/Gems/1.8/bin

潇烟暮雨 2024-10-01 01:43:16

您可以将它用于Rails 4,在gem文件gem“annotate”,“〜> 2.5.0”中添加gem并运行以下命令

rails g annotate_models:install

而不是

rails g annotate:install

然后运行以下命令以在模型类之后添加模式信息

bundle exec annotate -p after

,或者可以在之前使用以下命令

 bundle exec annotate -p before

You can use it for Rails 4, add gem in your gem file gem "annotate", "~> 2.5.0" and run following command

rails g annotate_models:install

instead of

rails g annotate:install

Then run following command to add schema information after model class

bundle exec annotate -p after

or can use following for before

 bundle exec annotate -p before
暖风昔人 2024-10-01 01:43:16

如果 bundle exec annotate 不起作用,请尝试:

rake annotate_models

If bundle exec annotate doesn't work, try:

rake annotate_models
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文