Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'require' is needed #19

Merged
merged 1 commit into from
Jan 30, 2022
Merged

'require' is needed #19

merged 1 commit into from
Jan 30, 2022

Conversation

komagata
Copy link
Contributor

@komagata komagata commented Jan 25, 2022

rake test has failed.

$ ruby -v
ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [arm64-darwin21]
$ bundle exec rake test
Traceback (most recent call last):
        11: from /Users/komagata/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `<main>'
        10: from /Users/komagata/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `select'
         9: from /Users/komagata/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `block in <main>'
         8: from /Users/komagata/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `require'
         7: from /Users/komagata/go/src/github.com/komagata/active_flag/test/active_flag_test.rb:1:in `<top (required)>'
         6: from /Users/komagata/go/src/github.com/komagata/active_flag/test/active_flag_test.rb:1:in `require'
         5: from /Users/komagata/go/src/github.com/komagata/active_flag/test/test_helper.rb:1:in `<top (required)>'
         4: from /Users/komagata/go/src/github.com/komagata/active_flag/test/test_helper.rb:1:in `require'
         3: from /Users/komagata/go/src/github.com/komagata/active_flag/lib/active_flag.rb:3:in `<top (required)>'
         2: from /Users/komagata/go/src/github.com/komagata/active_flag/lib/active_flag.rb:3:in `require'
         1: from /Users/komagata/go/src/github.com/komagata/active_flag/lib/active_flag/value.rb:1:in `<top (required)>'
/Users/komagata/go/src/github.com/komagata/active_flag/lib/active_flag/value.rb:2:in `<module:ActiveFlag>': uninitialized constant ActiveFlag::Set (NameError)
rake aborted!
Command failed with status (1)
/Users/komagata/.rbenv/versions/2.7.5/bin/bundle:25:in `load'
/Users/komagata/.rbenv/versions/2.7.5/bin/bundle:25:in `<main>'
Tasks: TOP => test
(See full trace by running task with --trace)

After this PR.

$ rake test
Run options: --seed 42457

# Running:

..................

Fabulous run in 0.012554s, 1433.8060 runs/s, 3026.9237 assertions/s.

18 runs, 38 assertions, 0 failures, 0 errors, 0 skips

@kenn
Copy link
Owner

kenn commented Jan 26, 2022

Do you know what's causing the issue? It seems to work with ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]

Run options: --seed 20236

# Running:

..................

Fabulous run in 0.036039s, 499.4589 runs/s, 1054.4133 assertions/s.

18 runs, 38 assertions, 0 failures, 0 errors, 0 skips

@komagata
Copy link
Contributor Author

komagata commented Jan 27, 2022

@kenn I also tried to run it on ruby 2.6.5.
But it didn't work.

M1 Mac may be the cause.

$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [-darwin21]
$ rake test
Traceback (most recent call last):
	15: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `<main>'
	14: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `select'
	13: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `block in <main>'
	12: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	11: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	10: from /Users/komagata/go/src/github.com/komagata/active_flag/test/active_flag_test.rb:1:in `<top (required)>'
	 9: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 8: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 7: from /Users/komagata/go/src/github.com/komagata/active_flag/test/test_helper.rb:1:in `<top (required)>'
	 6: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 5: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 4: from /Users/komagata/go/src/github.com/komagata/active_flag/lib/active_flag.rb:3:in `<top (required)>'
	 3: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 2: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 1: from /Users/komagata/go/src/github.com/komagata/active_flag/lib/active_flag/value.rb:1:in `<top (required)>'
/Users/komagata/go/src/github.com/komagata/active_flag/lib/active_flag/value.rb:2:in `<module:ActiveFlag>': uninitialized constant ActiveFlag::Set (NameError)
rake aborted!
Command failed with status (1)

Tasks: TOP => test
(See full trace by running task with --trace)

@kenn
Copy link
Owner

kenn commented Jan 27, 2022

I just tried on my M1 MacBook Pro 14 and it passes too. What happens if you actually use the library in your Rails dev env?

$ ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [-darwin21]
$ rake
Run options: --seed 25730

# Running:

..................

Fabulous run in 0.010088s, 1784.2982 runs/s, 3766.8517 assertions/s.

@komagata
Copy link
Contributor Author

It's not a rails dev env. But it may be a problem in my environment.

I'll ask other users later.

$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [-darwin21]
$ cd /tmp
$ git clone https://github.com/kenn/active_flag.git
Cloning into 'active_flag'...
remote: Enumerating objects: 203, done.
remote: Counting objects: 100% (66/66), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 203 (delta 51), reused 48 (delta 43), pack-reused 137
Receiving objects: 100% (203/203), 32.05 KiB | 5.34 MiB/s, done.
Resolving deltas: 100% (89/89), done.
$ cd active_flag
$ bundle i
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using minitest 5.15.0
Using tzinfo 2.0.4
Fetching zeitwerk 2.5.4
Fetching i18n 1.9.1
Using sqlite3 1.4.2
Using bundler 2.3.6
Installing zeitwerk 2.5.4
Installing i18n 1.9.1
Using activesupport 6.1.4.4
Using activemodel 6.1.4.4
Using activerecord 6.1.4.4
Using active_flag 1.5.1 from source at `.`
Bundle complete! 5 Gemfile dependencies, 12 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
$ rake test
Traceback (most recent call last):
	15: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `<main>'
	14: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `select'
	13: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `block in <main>'
	12: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	11: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	10: from /private/tmp/active_flag/test/active_flag_test.rb:1:in `<top (required)>'
	 9: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 8: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 7: from /private/tmp/active_flag/test/test_helper.rb:1:in `<top (required)>'
	 6: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 5: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 4: from /private/tmp/active_flag/lib/active_flag.rb:3:in `<top (required)>'
	 3: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 2: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 1: from /private/tmp/active_flag/lib/active_flag/value.rb:1:in `<top (required)>'
/private/tmp/active_flag/lib/active_flag/value.rb:2:in `<module:ActiveFlag>': uninitialized constant ActiveFlag::Set (NameError)
rake aborted!
Command failed with status (1)

Tasks: TOP => test
(See full trace by running task with --trace)

@kenn
Copy link
Owner

kenn commented Jan 29, 2022

Can you open CLI (pry or irb) and try to define an AR model with ActiveFlag there? If it still errors out, it would give us better information.

@kenn
Copy link
Owner

kenn commented Jan 29, 2022

Or ./bin/console in the directory could work, too

$ ./bin/console
2.6.6 :001 > ActiveFlag
 => ActiveFlag

@komagata
Copy link
Contributor Author

I did it.

$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [-darwin21]
$ bundle i
Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using i18n 1.9.1
Using minitest 5.15.0
Using tzinfo 2.0.4
Using zeitwerk 2.5.4
Using activesupport 6.1.4.4
Using activemodel 6.1.4.4
Using activerecord 6.1.4.4
Using active_flag 1.5.1 from source at `.`
Using bundler 2.3.6
Using sqlite3 1.4.2
Bundle complete! 5 Gemfile dependencies, 12 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
$ bundle exec ./bin/console
>> ActiveFlag
=> ActiveFlag
>> 

$ bundle exec rake test
Traceback (most recent call last):
	11: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `<main>'
	10: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `select'
	 9: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `block in <main>'
	 8: from /Users/komagata/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `require'
	 7: from /private/tmp/active_flag/test/active_flag_test.rb:1:in `<top (required)>'
	 6: from /private/tmp/active_flag/test/active_flag_test.rb:1:in `require'
	 5: from /private/tmp/active_flag/test/test_helper.rb:1:in `<top (required)>'
	 4: from /private/tmp/active_flag/test/test_helper.rb:1:in `require'
	 3: from /private/tmp/active_flag/lib/active_flag.rb:3:in `<top (required)>'
	 2: from /private/tmp/active_flag/lib/active_flag.rb:3:in `require'
	 1: from /private/tmp/active_flag/lib/active_flag/value.rb:1:in `<top (required)>'
/private/tmp/active_flag/lib/active_flag/value.rb:2:in `<module:ActiveFlag>': uninitialized constant ActiveFlag::Set (NameError)
rake aborted!
Command failed with status (1)
/Users/komagata/.rbenv/versions/2.6.5/bin/bundle:23:in `load'
/Users/komagata/.rbenv/versions/2.6.5/bin/bundle:23:in `<main>'
Tasks: TOP => test
(See full trace by running task with --trace)

@miyagawa
Copy link

miyagawa commented Jan 30, 2022

I can reproduce the error with bundler 2.3.6, but not with 2.1.4. It seems to me loading bundler/setup with the old version of Bundler has the side effect of loading set.rb for you:

➜  bundler -v                   
Bundler version 2.1.4
➜  ruby -rbundler/setup -e 'p Set'
Set
➜  gem i bundler
Fetching bundler-2.3.6.gem
Successfully installed bundler-2.3.6
1 gem installed
➜  bundler -v                   
Bundler version 2.3.6
➜  ruby -rbundler/setup -e 'p Set'
Traceback (most recent call last):
-e:1:in `<main>': uninitialized constant Set (NameError)

@miyagawa
Copy link

This seems to be the change introduced in Bundler 2.2.8, which removes the use of set.rb
rubygems/rubygems#4297

@kenn
Copy link
Owner

kenn commented Jan 30, 2022

Ah — good catch, thanks!

@kenn kenn merged commit cc2f439 into kenn:master Jan 30, 2022
@komagata komagata deleted the bug/no-require branch January 31, 2022 15:21
@komagata
Copy link
Contributor Author

komagata commented Feb 2, 2022

@miyagawa Oh Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants