samg / timetrap

Simple command line timetracker
http://rubygems.org/gems/timetrap
Other
1.48k stars 115 forks source link

Ruby/2.3.3 support #150

Closed jgphpc closed 4 years ago

jgphpc commented 7 years ago

I am not a Ruby expert hence apology in advance for my question. Whle i can install/use timetrap with Ruby/2.2.2, it fails with Ruby/2.3.3:

Ruby/2.3.3 (not ok)

$ gem install timetrap
Successfully installed timetrap-1.14.0
Parsing documentation for timetrap-1.14.0
Done installing documentation for timetrap after 0 seconds
1 gem installed

Ruby/2.2.2 (OK)

$ gem install timetrap
Fetching: chronic-0.10.2.gem (100%)
Successfully installed chronic-0.10.2
Fetching: sqlite3-1.3.12.gem (100%)
Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.12
Fetching: sequel-4.0.0.gem (100%)
Successfully installed sequel-4.0.0
Fetching: timetrap-1.14.0.gem (100%)
Successfully installed timetrap-1.14.0
Parsing documentation for chronic-0.10.2
Installing ri documentation for chronic-0.10.2
Parsing documentation for sqlite3-1.3.12
Installing ri documentation for sqlite3-1.3.12
Parsing documentation for sequel-4.0.0
Installing ri documentation for sequel-4.0.0
Parsing documentation for timetrap-1.14.0
Installing ri documentation for timetrap-1.14.0
Done installing documentation for chronic, sqlite3, sequel, timetrap after 24 seconds
4 gems installed

Any hint please ?

walm commented 7 years ago

I've same issue on a clean installation with ruby 2.3.3p222, and it seems to be not finding the gem's lookup path or something. Even that gem env all looks good.

You can get timetrap to run by using the dev_t command that will load it's lib correct with hardpath's. Just make sure you have just one version of timetrap installed I guess.

jgphpc commented 7 years ago

ok, thanks for the hint, i would say you can close my issue.

legrostdg commented 7 years ago

I have the same problem. Running dev_t works, but sounds like a workaround...

dashkb commented 7 years ago

I'd love to help you all (because I love this gem). @jgphpc your gem search path looks weird; can you share more about the system you're on and how you installed Ruby? Are you able to successfully install and use other global CLI gems? (you can try one of mine, gem install dburl to test if you want.)

/cc @walm @legrostdg

trust, but verify: dashkb/dburl

legrostdg commented 7 years ago
$ gem install --user-install dburl
Successfully installed dburl-0.1.4
Parsing documentation for dburl-0.1.4
Installing ri documentation for dburl-0.1.4
Done installing documentation for dburl after 0 seconds
1 gem installed
$ dburl 
Usage: dburl [DATABASE_URL]

compared to

$ gem install --user-install timetrap
Successfully installed timetrap-1.14.1
Parsing documentation for timetrap-1.14.1
Done installing documentation for timetrap after 0 seconds
1 gem installed
$ t
cannot load such file -- timetrap: ["/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'", "/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'", "/home/user/.gem/ruby/2.3.0/gems/timetrap-1.14.1/bin/t:3:in `<top (required)>'", "/home/user/.gem/ruby/2.3.0/bin/t:22:in `load'", "/home/user/.gem/ruby/2.3.0/bin/t:22:in `<main>'"]

I use Debian unstable, with ruby installed with apt install ruby

$ ruby --version
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]
jgphpc commented 7 years ago

I retried with ruby/2.4.0 and timetrap/1.14.1 and the issue is not present anymore:

Suse

RedHat

I could try on other systems too but i consider my problem to be resolved.

dashkb commented 7 years ago

Yeah @jgphpc I'd have to guess something was messed up with your install of 2.3.3.

@legrostdg does it work for you on the latest ruby?

EdwinHoksberg commented 7 years ago

Hi, I am getting the same error:

cannot load such file -- timetrap: ["/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'", "/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'", "/var/lib/gems/2.3.0/gems/timetrap-1.14.1/bin/timetrap:3:in `<top (required)>'", "/usr/local/bin/timetrap:22:in `load'", "/usr/local/bin/timetrap:22:in `<main>'"]

I've installed timetrap with: sudo gem install timetrap My Ruby/gem version:

$ ruby --version
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]

$ gem --version
2.5.2

My OS is Debian 9.0 (Sid/Unstable)

adamplumb commented 7 years ago

I'm having this same issue on a recent install of Fedora 25 with the default ruby 2.3.3.

ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
dashkb commented 7 years ago

If y'all can set up an easy repro (like in a docker container or something) then I'll try to debug...

My advice failing that is to NOT use the system Ruby (or apt/yum/whatever) and use either RVM or Homebrew/Linuxbrew to install a Ruby owned by your user, so you don't need sudo to install gems. Ruby is up to 2.4 anyway.

ToadJamb commented 7 years ago

I just realized that an issue I opened (https://github.com/samg/timetrap/issues/159) may actually be a duplicate of this. For the record, I am using rvm on Ubuntu.

@dashkb "Ruby is up to 2.4 anyway" is not an acceptable answer for 2 reasons:

  1. This issue was raised PRIOR to 2.4 being released, so that response implies that maintainers are willing to just wait until new versions come out to see if it fixes itself. It's understandable that people are busy and have other priorities. It is not understandable to say "Oh. Look at that. We waited long enough that a new version came out and now it works. Everyone upgrade!"

  2. Even if it works under 2.4.x, 2.3.3 is still a supported ruby version and Timetrap should work as expected. There are many cases where projects cannot be upgraded trivially and then you're asking users to change ruby versions, switch terminals, or hack their binaries (my interim solution) to use timetrap.

As a final thought, I'm not 100% convinced this is timetrap's fault, but I have no trouble with any other gems under 2.3.3, so it seems likely that it is and at the very least seems like it's reasonable for the timetrap community to help track down the problem.

ToadJamb commented 7 years ago

I spent way more time on this than I have, but here's what I found.

This line https://github.com/samg/timetrap/blob/master/lib/Getopt/Declare.rb#L1267 checks $@, which has already been flagged, but it is presumably there to catch errors on the previous line. In my case, clearing $@ prior to err = code(@caller) allows timetrap to work as expected.

A little more examination shows that the error appears to occur prior to even loading lib/timetrap.rb, so it may be a combination of some changes in ruby 2.3.3 and the fact that timetrap is relying on global error variables.

Something like $@ = nil at the top of lib/timetrap.rb would fix the problem. It's weird to be getting cannot load such file -- timetrap when clearly that file IS actually in the process of loading.

dashkb commented 7 years ago

@toadjamb sorry I frustrated you with my suggestions.

So I suggested upgrading because I suspected it might be an environment problem, and upgrading Ruby (which is always a good idea unless another factor makes it impractical) is either a helpful diagnosis step, or the fix, depending on how much you care about getting it working on 2.3.

Edit: @ToadJamb 2.4 wasn't my only suggestion; if you're using 2.3 installed through a package manager or pre-installed on your system I suggest you build/install or use rvm or https://github.com/postmodern/ruby-install; something that results in a Ruby compiled on your system and owned by your user. (Can't edit an email reply to add strike-through; but ignore that sentence)

Sorry- I can't read; you said you're using rvm; and you've got more useful info in #159. I now have zero suggestions for you because your environment (afaict) is the same as mine. 2.4 might not even help you. But, since you're using rvm, it would be a very low-cost and low-impact solution for you to try.

samg commented 7 years ago

I was able to replicate this issue. As far as I can tell it's related to some subtle difference in how load_paths are set up in new ruby installs. I believe I've fixed the issue in https://rubygems.org/gems/timetrap/versions/1.14.2 by updating the syntax for requiring the timetrap lib files relative to the bin.

Could you let me know if this resolves the error on your install and close out the issue if so.

Thanks!