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

tj3d issue and work-around #168

Open
John57 opened this issue Apr 12, 2015 · 2 comments
Open

tj3d issue and work-around #168

John57 opened this issue Apr 12, 2015 · 2 comments

Comments

@John57
Copy link

John57 commented Apr 12, 2015

I wouldn't call this a fix, but it made the issue (which seem to be somewhat common) go away. The problem was my issue with tj3d. I started with an absolutely fresh and up-to-date Fedora 21 installation (x86_64), taskjuggler installed via RPM which automatically installed ruby with YAML support.

Kernel: 3.19.3-200.fc21.x86_64
rubygem-taskjuggler-3.5.0-1.fc21
ruby-2.1.5-26.fc21.x86_64

tj3 works like a charm. I use it HEAVILY. Trying to start using the tj3d and tj3webd functionality to take it to the next level, I tried for the first time to bring up tj3d with a project I spend more time working on that I should. That failed. I it would get stuck trying to import the project. So I grabbed the tutorial.tjp and tried loading that. This attempt failed as well. So I started exploring and found that many folks have experienced similar issues. There were some suggestions regarding the confirmation of YAML support. Those tests passed for me.

$ ruby -r yaml -e "YAML::load_file('.taskjugglerrc')"
$ echo $?
0

So I attempted to throw tj3d into heavy debugging mode:
tj3d -d -w --debug -p 12345 -c .taskjugglerrc tutorial.tjp
I chose a crazy port that wasn't default so it would be easier to spot in the log files
The .taskjugglerrc was straight from the tutorial (just one level higher on the debugging):

$ cat .taskjugglerrc 
_global:
  authKey: topsecret
  webServerPort: 8080
  _log:
    logLevel: 4
    outputLevel: 4

Here is the stderr log file created during my last failed run:

$ cat tj3d.ps.2196.stderr
Exception `SecurityError' at /usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TjTime.rb:79 - Insecure operation - []=
Exception `SecurityError' at /usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/daemon/ProjectServer.rb:113 - Insecure operation - []=
Exception `RuntimeError' at /usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/MessageHandler.rb:300 - RuntimeError
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/MessageHandler.rb:300:in `addMessage': RuntimeError (RuntimeError)
        from /usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/MessageHandler.rb:189:in `fatal'
        from /usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/MessageHandler.rb:311:in `fatal'
        from /usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/Tj3AppBase.rb:160:in `rescue in main'
        from /usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/Tj3AppBase.rb:126:in `main'
        from /usr/share/gems/gems/taskjuggler-3.5.0/lib/tj3d.rb:15:in `<top (required)>'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/gems/gems/taskjuggler-3.5.0/bin/tj3d:4:in `<top (required)>'
        from /bin/tj3d:23:in `load'
        from /bin/tj3d:23:in `<main>'
Fatal: Insecure operation - []=
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TjTime.rb:79:in `[]='
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TjTime.rb:79:in `checkTimeZone'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TjpSyntaxRules.rb:7342:in `block in rule_validTimeZone'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TextParser.rb:393:in `call'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TextParser.rb:393:in `finishPattern'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TextParser.rb:345:in `block in parseFSM'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TextParser.rb:271:in `loop'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TextParser.rb:271:in `parseFSM'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TextParser.rb:200:in `parse'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TaskJuggler.rb:66:in `block in parse'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TaskJuggler.rb:54:in `each'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/TaskJuggler.rb:54:in `parse'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/daemon/ProjectServer.rb:154:in `loadProject'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/daemon/ProjectServer.rb:290:in `block (2 levels) in startHousekeeping'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/daemon/ProjectServer.rb:283:in `loop'
/usr/share/gems/gems/taskjuggler-3.5.0/lib/taskjuggler/daemon/ProjectServer.rb:283:in `block in startHousekeeping'

*******************************************************************************
You have triggered a bug in TaskJuggler version 3.5.0!
Please see the user manual on how to get this bug fixed!
http://www.taskjuggler.org/tj3/manual/Reporting_Bugs.html#Reporting_Bugs_and_Feature_Requests
*******************************************************************************

So, I went exploring the TjTime.rb file mentioned in the log file above. Line 79 looks like it is trying to set the TZ environment variable.

77      # Restore TZ if it was set earlier.
78      if tz
79        ENV['TZ'] = tz
80      else
81        ENV.delete('TZ')
82      end

I have never written a single line of ruby - ever. I set and exported a TZ environment variable and achieved the same results as before - failure. Looking closer at the stderr output I found this line and did a little more research about setting SAFE in ruby.
Fatal: Insecure operation - []=
Not knowing anything about anything, I then commented out line 79. That's it. Just commented it out. I unset the previously set TZ environment variable.

The who.le show works now. All tutorial examples work. My large project file works with all of it's crazy includes and booking statement files. The web interface works. I am running the very simple .taskjugglerrc file as above and can run tj3d and tj3webd without any arguments - like I said straight from the tutorial.

This is just a fantastic project and want to help in any way I can. I wouldn't call this a fix, but it now causes everything that I know to try from the tutorial --- to work. Maybe this will help others.

Please use the suggestion to alter TjTime.rb at your own risk. I have only done basic testing, but wow...

Thank you to the group for all of your efforts.

By the way, this is my first post / issue with my just created github account. - so please flame me too hard for a newbie style post.

@PiQuer
Copy link

PiQuer commented May 21, 2015

Based on this I came up with different workaround. It requires ruby-activesupport, but should provide a more robust way to check if a timezone is valid:

--- /usr/lib/ruby/vendor_ruby/2.2.0/taskjuggler/TjTime.rb       2014-12-29 15:49:57.000000000 +0100
+++ TjTime.rb   2015-05-21 02:04:47.899213942 +0200
@@ -13,6 +13,7 @@

 require 'time'
 require 'date'
+require 'active_support/time'

 class TaskJuggler

@@ -59,29 +60,8 @@
     # Check if +zone+ is a valid time zone.
     def TjTime.checkTimeZone(zone)
       return true if zone == 'UTC'
-
-      # Valid time zones must be of the form 'Region/City'
-      return false unless zone.include?('/')
-
-      # Save curent value of TZ
-      tz = ENV['TZ']
-      ENV['TZ'] = zone
-      newZone = Time.new.zone
-      # If the time zone is valid, the OS can convert a zone like
-      # 'America/Denver' into 'MST'. Unknown time zones are either not
-      # converted or cause a fallback to UTC.
-      # Since glibc 2.10 Time.new.zone only return the region for illegal
-      # zones instead of the full zone string like it does on earlier
-      # versions.
-      region = zone[0..zone.index('/') - 1]
-      res = (newZone != zone && newZone != region && newZone != 'UTC')
-      # Restore TZ if it was set earlier.
-      if tz
-        ENV['TZ'] = tz
-      else
-        ENV.delete('TZ')
-      end
-      res
+      return true if ActiveSupport::TimeZone::MAPPING.has_value?(zone)
+      return false
     end

     # Set a new active time zone. _zone_ must be a valid String known to the

@deepfire
Copy link

deepfire commented Nov 5, 2015

The same import failure happens to me:

[deepfire@andromedae:~/Projects]$ tj3client -d --debug add tutorial.tjp 
TaskJuggler v3.5.0 - A Project Management Software

Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
              by Chris Schlaeger <chris@linux.com>

This program is free software; you can redistribute it and/or modify it under
the terms of version 2 of the GNU General Public License as published by the
Free Software Foundation.

Exception `TypeError' at /nix/store/3jvfridc2qghz1b78sw0irl16xg3walw-ruby-2.2.2-p0/lib/ruby/2.2.0/drb/drb.rb:565 - can't dump IO
Exception `TypeError' at /nix/store/3jvfridc2qghz1b78sw0irl16xg3walw-ruby-2.2.2-p0/lib/ruby/2.2.0/drb/drb.rb:529 - can't dump IO
Exception `TypeError' at /nix/store/3jvfridc2qghz1b78sw0irl16xg3walw-ruby-2.2.2-p0/lib/ruby/2.2.0/drb/drb.rb:529 - can't dump IO
Exception `TypeError' at /nix/store/3jvfridc2qghz1b78sw0irl16xg3walw-ruby-2.2.2-p0/lib/ruby/2.2.0/drb/drb.rb:529 - can't dump IO
Debug: IO is now routed to the client
Debug: Accepted authentication key for command 'loadProject'
Exception `SecurityError' at /nix/store/hcv155l31ra3xd714vjbpx50xjxvqkkm-taskjuggler-3.5.0/lib/ruby/gems/2.2.2/gems/taskjuggler-3.5.0/lib/taskjuggler/TjTime.rb:80 - Insecure operation - []=
Warning: Projects(s) tutorial.tjp could not be added

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

No branches or pull requests

3 participants