paper-trail-gem / paper_trail

Track changes to your rails models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Couldn't find paper trail generator

pkuruppu opened this issue · comments

Hey guys -
Using Rails 4.1, Ruby 2.1.4

I've entered gem 'paper_trail', '~> 3.0.6' into my Gemfile
I've bundled successfully, but when I bundle exec rails generate paper_trail:install I get:

Could not find generator paper_trail:install.

Seems like a very minute problem - am I missing something here?

Did you run bundle install first? And make sure the gem is not in a group on the Gemfile..

What happens when you run bundle show paper_trail?

I've ran bundle install, and it's not in a group on the Gemfile. When I run bundle show, it does list the gem

Is it listed in the generator pool when you run just bundle exec rails g?

It's not listed

On Wed, Jan 7, 2015 at 3:15 PM, Ben Atkins notifications@github.com wrote:

Is it listed as a generator option when you run just bundle exec rails g?


Reply to this email directly or view it on GitHub
#459 (comment)
.

Hmmmm, I just tried with a fresh app of Rails 4.1.8 and it seemed to work for me so I'm not sure what the issue could be...

Strange. I've used Papertrail on other projects and this is the first time
I've had an issue with the generator

On Wed, Jan 7, 2015 at 3:19 PM, Ben Atkins notifications@github.com wrote:

Hmmmm, I just tried with a fresh app of Rails 4.1.8 and it seemed to work
for me so I'm not sure what the issue could be...


Reply to this email directly or view it on GitHub
#459 (comment)
.

Are generators from other gems showing up in that list?

Yes, other gem generators are showing up

On Jan 8, 2015 7:48 AM, "Ben Atkins" notifications@github.com wrote:

Are generators from other gems showing up in that list?


Reply to this email directly or view it on GitHub
#459 (comment)
.

Were you ever able to sort out what was going on here? Perhaps try upgrading Rails?

No I've been unable to figure it out..I decided to table it for now to do
something else.

On Wed, Jan 14, 2015 at 4:51 PM, Ben Atkins notifications@github.com
wrote:

Were you ever able to sort out what was going on here? Perhaps try
upgrading Rails?


Reply to this email directly or view it on GitHub
#459 (comment)
.

You can always just copy the migration contents into a blank migration file if you really can't get it to work.

Sent from my iPhone

On Jan 14, 2015, at 8:05 PM, pkuruppu notifications@github.com wrote:

No I've been unable to figure it out..I decided to table it for now to do
something else.

On Wed, Jan 14, 2015 at 4:51 PM, Ben Atkins notifications@github.com
wrote:

Were you ever able to sort out what was going on here? Perhaps try
upgrading Rails?


Reply to this email directly or view it on GitHub
#459 (comment)
.


Reply to this email directly or view it on GitHub.

This is happening for me too :(

If someone can provide a failing dummy app I can debug it more easily. I was unable to reproduce this, which makes it difficult to determine a cause.

For me it worked when sourcing the gem from Github master. It didn't work when using the rubygems version suggested in the readme.

@chrise86 - What version were you sourcing prior to sourcing from Github master? 4.0.0.beta2? I am aware that there are some bugs with the 4.0.0.beta releases I've made up until now, and that the current master is now stable and I plan on making another release soon, however, since those releases were beta I didn't feel the need to yank them.

is this a dup of #494?

I was experiencing the same issue in an app, after I switched to another version or ruby (using rvm) it magically appeared.

One curious thing was that, on the same environment I was having the problems, I was able to create a new rails app and the generator appeared.

This is the app in question in which I was experiencing the problems is this:
https://github.com/merlos/panatrans-api/tree/features/auditable
This is the last commit (before I solved the problem)
(merlos/panatrans-api@95a6258)

I guess that it may be related with any "base" gem or something like that. These are the steps I followed:

# generator not working 

$ ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
$ rails --version
Rails 4.1.6

# Change to another ruby version

$ rvm ruby-2.1.2    # I had it already installed

$ ruby --version
$ ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
$ rails --version
Could not find execjs-2.4.0 in any of the sources
Run `bundle install` to install missing gems.

# So, I had to udpate rails gems

$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.6
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.6
Using rack 1.5.2
Using rack-test 0.6.3
Using actionpack 4.1.6
Using mime-types 2.4.3
Using mail 2.6.3
Using actionmailer 4.1.6
Using activemodel 4.1.6
Using arel 5.0.1.20140414130214
Using activerecord 4.1.6
Using acts_as_list 0.6.0
Using coffee-script-source 1.9.1
Installing execjs 2.4.0
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.6
Using coffee-rails 4.0.1
Installing git 1.2.9.1
Using haversine 0.3.0
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.2.8
Using jquery-rails 3.1.2
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Installing paper_trail 4.0.0.beta2
Using pg 0.17.1
Using bundler 1.6.3
Using tilt 1.4.1
Using sprockets 2.12.3
Using sprockets-rails 2.2.4
Using rails 4.1.6
Using rails_serve_static_assets 0.0.2
Using rails_stdout_logging 0.0.3
Using rails_12factor 0.0.2
Using rdoc 4.2.0
Using sass 3.2.19
Using sass-rails 4.0.5
Using sdoc 0.4.1
Using spring 1.3.2
Using sqlite3 1.3.10
Using turbolinks 2.5.3
Installing uglifier 2.7.1
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

# NOW IT APPEARS ! :-?

$ rails g
Usage: rails generate GENERATOR [args] [options]

General options:
  -h, [--help]     # Print generator's options and usage
  -p, [--pretend]  # Run but do not make any changes
  -f, [--force]    # Overwrite files that already exist
  -s, [--skip]     # Skip files that already exist
  -q, [--quiet]    # Suppress status output

Please choose a generator below.

Rails:
  assets
  controller
  generator
  helper
  integration_test
  jbuilder
  mailer
  migration
  model
  resource
  scaffold
  scaffold_controller
  task

Coffee:
  coffee:assets

Jquery:
  jquery:install

Js:
  js:assets

PaperTrail:
  paper_trail:install

TestUnit:
  test_unit:generator
  test_unit:plugin

Thanks!
Juan.

@merlos - Thanks for the detailed report. Just wanted to clarify though, what do you think is the culprit here then? Ruby 2.1.x?

I was unable to reproduce this. I tried:

mkdir pt_issue_459 && cd pt_issue_459
echo "2.1.1" > .ruby_version
cat > Gemfile <<EOF
source 'https://rubygems.org'
gem "rails", "4.1.6"
gem "paper_trail", git: "git@github.com:airblade/paper_trail.git"
EOF
bundle
bundle exec rails new . --skip-gemfile --skip-spring
bundle exec rails g | grep paper_trail # paper_trail:install

Just guessing, but this may be a case of a poorly configured rvm or perhaps failing to use bundle exec.

@pkuruppu @merlos can you try the above and let us know what happens?

@jaredbeck It worked for me (I had to use https://github.com/airblade/paper_trail.git instead of git@github.com:airblade/paper_trail.git, something regarding permissions... ).

As I told in my previous comment, even before I solved the issue by setting a different ruby version I was able to create a new app with ruby 2.1.1 and the paper_trail generator appeared. It seemed to be a weird issue that affected only in the app I was working on. BTW I tried with/without bundle exec several times.

@batter My guess based on ignorance: some uncommon incompatibility with a particular version of a gem that was in my app.

Ok I'm tentatively ready to close this, just because I really don't have the faintest idea what could/would cause this and I don't know that there's anything we can do to "fix" it. @jaredbeck - good point that, when in doubt, you should always run the commands with bundle exec just in case (even though rvm makes it possible to avoid it).

+1 to close it.

Just a note to this, I was having this problem on Ruby 2.1.6, changed to Ruby 2.0.0 and all works fine now.

commented

Coming back to this I've been able to fix it for myself:
The problem was that after I bundled and ran the generator it returned the following message:

Could not find generator paper_trail:install.

After running 'gem list paper_trail' I saw it returned 2 versions.

paper_trail (4.0.0.rc1, 2.7.2)

Then I went to my Gemfile and set the version I wanted to use:

gem 'paper_trail', '4.0.0.rc1'

And it worked! ('bundle exec rails generator paper_trail:install')

create db/migrate/20150602090759_create_versions.rb

Hope it helps anyone.

had the same issue after switching ruby version. tried uninstalling and re-installing paper_trail gem a couple of times and finally got it to work.

Just to prove there are a million + 1 ways to mess things up, I experienced this same error.

Then realized I'd added papertrail instead of paper_trail to my Gemfile.

In my case an error was nice enough to offer explanation how to fix itself - comment out: source 'https://rubygems.org' in Gemfile. Never had this error before. Thank you for the gem!

Just to point out that I had the same issue using ruby-2.3.1. After I switched to ruby-2.2.4 everything worked as expected! :)
I thought it might be of help to somebody experiencing this.

For anyone wandering here from search engines, looks like this is an issue specifically with RVM only. On my linux dev machine, this worked as expected, however on my RVM using Ruby 2.3.1 I faced same issue as OP. You may just want to copy the migration file and commit it.

This is happening to me with ruby 2.5 and rails 5.1.4. I get:

bundle exec rails generate paper_trail:install
Running via Spring preloader in process 4114
Could not find generator 'paper_trail:install'. Maybe you meant 'pundit:install', 'rspec:install' or 'devise:install'

I am not using rvm.

I have this issue as well in ruby 2.5.1 and rails 5.2

Had same issue with Ruby 2.5.0 and Rails 5.2.
Resolved issue with:
spring stop
Afterwards generate worked without problems. Hopes this would help to someone.

commented

Had same issue with Ruby 2.5.0 and Rails 5.2.
Resolved issue with:
spring stop
Afterwards generate worked without problems. Hopes this would help to someone.

Thank you!

Just had this exact problem, I solved it when I realized that I picked the wrong gem papertrail instead of paper_trail.