Defect #4610
closedundefined method `env_table' for nil:NilClass (NoMethodError) with rev 3335
100%
Description
Hi, we're evaluation CM solutions and one of my team members recommended Redmine. I've followed the instructions on how to install/configure it (Using trunk rev. 3335) but I get this error when attempting to run dispatch.cgi:
undefined method `env_table' for nil:NilClass (NoMethodError)
I've done the rake db:migrate RAILS_ENV=production successfully.
Any ideas?
Related issues
Updated by Andrea Barni almost 15 years ago
What OS are you using? I had the same problem yesterday on Debian Lenny + Apache2 + mod_fcgi. After more than three hours of troubleshooting I gave up and replaced mod_fcgi with [[Passenger http://www.modrails.com/]]: it worked like a charm.
I think the problem is related to Rails 2.3.5 and fcgi.
Updated by Emilio Escobar almost 15 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
That did it... Thanks for the info! Someone should probably note on the HowTo page that if using Rails 2.3.5 then go with Passenger.
Thanks again!
Updated by Jean-Philippe Lang almost 15 years ago
- Status changed from Resolved to Closed
- Resolution set to Cant reproduce
FWIW, redmine.org runs with fcgid and rails 2.3.5
Updated by Matteo Giaccone almost 15 years ago
i had the same issue, resolved with passenger :)
Updated by Bryce Nordgren over 14 years ago
- Status changed from Closed to Reopened
I'm getting the same problem. It also appears to be a currently unresolved issue on the forums, with somewhat confusing "resolutions". Most solutions tend to point to the commercial product "Passenger", which is out of scope for my current use; skirting this problem instead of solving it.
On Win XP / XAMPP-win 1.7.3, my starting point is a freshly installed instance of Redmine, which I have verified with the webrick server and a browser pointed at localhost:3000. Attempting to run Redmine under a sub-url "/redmine" using apache (where I "Alias" /redmine to the appropriate directory) leads to:
[Thu Mar 04 16:01:32 2010] [error] [client 127.0.0.1] Premature end of script headers: dispatch.cgi [Thu Mar 04 16:01:32 2010] [error] [client 127.0.0.1] C:/Redmine/public/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement\r [Thu Mar 04 16:01:32 2010] [error] [client 127.0.0.1] C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/dispatcher.rb:24: warning: already initialized constant Dispatcher\r [Thu Mar 04 16:01:32 2010] [error] [client 127.0.0.1] C:/Redmine/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `__send__': undefined method `env_table' for nil:NilClass (NoMethodError)\r [Thu Mar 04 16:01:32 2010] [error] [client 127.0.0.1] \tfrom C:/Redmine/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `dispatch_cgi'\r [Thu Mar 04 16:01:32 2010] [error] [client 127.0.0.1] \tfrom C:/Redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi'\r [Thu Mar 04 16:01:32 2010] [error] [client 127.0.0.1] \tfrom C:/Redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:27:in `dispatch'\r [Thu Mar 04 16:01:32 2010] [error] [client 127.0.0.1] \tfrom C:/Redmine/public/dispatch.cgi:11\r
About your application's environment Ruby version 1.8.7 (i386-mingw32) RubyGems version 1.3.6 Rack version 1.0 Rails version 2.3.5 Active Record version 2.3.5 Active Resource version 2.3.5 Action Mailer version 2.3.5 Active Support version 2.3.5 Application root C:/Redmine Environment production Database adapter mysql Database schema version 20100221100219
Updated by Bryce Nordgren over 14 years ago
Ah, I forgot to mention: I'm running Redmine 0.9.3.
Updated by Mirek Kratochvil over 14 years ago
exactly the same problem here.
Just to dump my environment...
Ruby version 1.8.7 (x86_64-linux)
RubyGems version 1.3.5
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Edge Rails revision unknown
Application root /var/www/someweb.org/t
Environment production
Database adapter postgresql
Database schema version 20100221100219
--
Distro: Gentoo amd64
GCC: 4.1.2
Passenger is not an option for me (i need to run it on hosting with plain CGI (and I dont really care about speed)).
I tracked the problem to a point where it seems that cgi object that needs to be passed to rails/actionpack/lib/action_controller/cgi_process.rb:22 just isn't created somehow. Creating it manually in dispatch.cgi and passing it on, like this:
require 'cgi'
Dispatcher.dispatch(CGI.new)
..moves the application a little further, but it then fails on some other error.
Thanks for anything useful
--mk
Updated by Felix Schäfer over 14 years ago
Could you please confirm this is still a problem with current stable/trunk, provide the redmine version used to test as well as the output of script/about
and what rails server you are using? A reliable way to reproduce would make debugging this that much easier too.
(Oh, and to comment on note 5 here, passenger is not a commercial product, they just sell support for it, the software is free)
Updated by Andrea Barni over 14 years ago
Sorry, but I am unable to rollback to my previous server configuration (apache+mod_fcgi) :(
Updated by Felix Schäfer over 14 years ago
Andrea Barni wrote:
Sorry, but I am unable to rollback to my previous server configuration (apache+mod_fcgi) :(
What do you use now?
Updated by Andrea Barni over 14 years ago
Felix Schäfer wrote:
What do you use now?
Apache2 plus Passenger and, as I already said, it works like a charm; I've also seen a speed bump after switching to this configuration.
Updated by Felix Schäfer over 14 years ago
Ok, if no one steps up with an error report on current stable or trunk and a way to reproduce, I'll close this in a few days.
Updated by Steve Gula over 14 years ago
[Fri Jul 09 20:23:35 2010] [error] [client 172.16.1.111]
[Fri Jul 09 20:23:37 2010] [error] [client 172.16.1.111] /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/cgi_process.rb:22:in `__send__'
[Fri Jul 09 20:23:37 2010] [error] [client 172.16.1.111] :
[Fri Jul 09 20:23:37 2010] [error] [client 172.16.1.111] undefined method `env_table' for nil:NilClass
[Fri Jul 09 20:23:37 2010] [error] [client 172.16.1.111] (
[Fri Jul 09 20:23:37 2010] [error] [client 172.16.1.111] NoMethodError
[Fri Jul 09 20:23:37 2010] [error] [client 172.16.1.111] )
RedHat Enterprise 5 w/ SELinux enabled
Apache/2.2.15 (Unix)
Passenger 2.2.15
Ruby 1.8.7
gem 1.3.7
gem
Updated by Steve Gula over 14 years ago
using dispatch.cgi.example copied over to dispatch.cgi
Updated by Steve Gula over 14 years ago
actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
cgi_multipart_eof_fix (2.5.0)
daemons (1.1.0)
fastthread (1.0.7)
gem_plugin (0.2.3)
mongrel (1.1.5)
mongrel_cluster (1.0.5)
passenger (2.2.15)
rack (1.2.1)
rails (2.3.8)
rake (0.8.7)
sqlite3-ruby (1.2.5)
Updated by Felix Schäfer over 14 years ago
Steve Gula wrote:
RedHat Enterprise 5 w/ SELinux enabled
Apache/2.2.15 (Unix)
Passenger 2.2.15
Ruby 1.8.7
gem 1.3.7
Are you trying to run redmine with passenger or cgi? Also note that redmine needs rails 2.3.5 and rack 1.0 or 1.0.1 (see RedmineInstall), you can install those with gem install <package> -v=<version>
IIRC.
Updated by Steve Gula over 14 years ago
I'm trying to do it through Apache w/ mod_rails(passenger)
So having newer versions of the required gems is bad? ... that's new to me. I'll uninstall 2.3.8 and get 2.3.8 installed.
Updated by Felix Schäfer over 14 years ago
Steve Gula wrote:
I'm trying to do it through Apache w/ mod_rails(passenger)
Well, from your logs Apache tries to use cgi. Remove the .htaccess
in the public directory of redmine.
So having newer versions of the required gems is bad? ... that's new to me. I'll uninstall 2.3.8 and get 2.3.8 installed.
In this case yes, the installation page also specifically says the exact versions are required, not "that version or newer". You don't need to uninstall 2.3.8 though, just install 2.3.5, ruby gems should be able to handle concurrent versions.
Updated by Steve Gula over 14 years ago
I'm willing to believe that most of these issues lie in working within SELinux.. at least almost all of mine did.
Updated by Felix Schäfer over 14 years ago
That would have been the next stumbling step I would have made you aware of, that passenger needs some extra SELinux settings on most distributions using it. Have you been able to get everything running with passenger?
Updated by Charles Canato over 14 years ago
- Status changed from Closed to Reopened
I'm truly sorry for reopening this bug, I was more or less following it, but missed these last messages based on the latest stable release.
I keep on having this problem. My system is a non-updatable (except for source building) SLES10 x64 one (can't wait until the guys here move everything to a Debian server), and not running many specific things.
I installed the correct versions, but was having the same problem about a month ago, when trying to deploy v0.9.4. According to Felix's instructions, I deleted everything and tried v0.9.6 from scratch, following the instructions from the wiki.
It runs okay on Webrick, as expected, but can't run it on Apache using CGI. I deployed it on a sub-URI (/bt, correctly aliased, and updated the environment.rb with the Rails::Utils solution), since I already have two apps at this server and they must keep on running there. The error messages I have are exactly the same ones as described previously, but anyway, I'll copy them here for you to see if I'm missing something. I'm really having a hard time trying to run it. :-(
This is the result of running dispatch.cgi, but I have the same messages on Apache error log:
[22:13]charlie:/var/www/html/redmine/public> ./dispatch.cgi ./../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/dispatcher.rb:24: warning: already initialized constant Dispatcher /var/www/html/redmine/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `__send__': undefined method `env_table' for nil:NilClass (NoMethodError) from /var/www/html/redmine/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `dispatch_cgi' from /var/www/html/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi' from /var/www/html/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:27:in `dispatch' from ./dispatch.cgi:10
It doesn't change a bit whether I use the copy of dispatch.cgi.example (as dispatch.cgi) as given, or if I update its ruby path and the "require dispatcher" command.
Moving/renaming rails folder out of redmine (to try it with my fresh rails 2.3.5 installation) only changes the paths mentioned in the messages.
About your application's environment Ruby version 1.8.7 (x86_64-linux) RubyGems version 1.3.7 Rack version 1.0 Rails version 2.3.5 Active Record version 2.3.5 Active Resource version 2.3.5 Action Mailer version 2.3.5 Active Support version 2.3.5 Edge Rails revision unknown Application root /var/www/html/redmine Environment development Database adapter postgresql Database schema version 20100221100219
Unfortunately, the steps to reproduce are simply following the instructions to install it. :-(
While I don't know what more to try, it's possible that I'll soon try it with fastcgi or fcgi, although I already had no success when trying them with v0.9.4. The Passenger solution is the only one I still didn't try, and althought it might work, I still consider this a bug. Don't know if it's only a Redmine bug, however.
As I see it may be hard to reproduce it if you don't have the same SLES10 system as mine, I may consider giving some monitored/controlled access to the server if it might help to diagnose and add real value to Redmine.
Updated by Felix Schäfer over 14 years ago
Charles Canato wrote:
I'm truly sorry for reopening this bug, I was more or less following it, but missed these last messages based on the latest stable release.
I still maintain it's some wonky configuration problem which should be discussed in the forums, but we'll keep the already rather long discussion here.
While I don't know what more to try, it's possible that I'll soon try it with fastcgi or fcgi, although I already had no success when trying them with v0.9.4. The Passenger solution is the only one I still didn't try, and althought it might work, I still consider this a bug. Don't know if it's only a Redmine bug, however.
If it really is a bug, it will more likely be one of rails than one of redmine.
Anyway, back to the drawing board. IIRC the causes for this problem boil down to: SELinux misconfiguration or wrong rack version. I'll let you dabble with the SELinux stuff because the only experience I have with it is that I knew how to turn it off, but for the rack version thing, and although script/about
tells you it's rack 1.0, have a look at gem list
, if possible even as the user the cgi should eventually run as, and see if there are other versions than 1.0. Please also try to grab 1.0.1, not sure what that one fixed, but redmine runs well with it and it might contain a fix for this.
Updated by Steve Gula over 14 years ago
how to tell if it's SELinux:
as root run "setenforce 0" and restart apache/httpd then try to view redmine in your browser ... if it works then it's SELinux .. if it's SELinux the following should work:
(as root)
mv /var/log/audit/audit.log /var/log/audit.log.old
touch /var/log/audit/audit.log
chmod 600 /var/log/audit/audit.log
service auditd restart
setenforce 0
service httpd restart
tail -f /var/log/audit/audit.log
((access redmine through your web browser and make sure your tail shows some output.. if it does, ctrl+c your tail ))
cat /var/log/audit/audit.log | audit2allow -M redmine
semodule -i redmine.pp
setenforce 1
service httpd restart
((verify again through your browser that Redmine is functioning.. these steps may have to be performed more than once as you slowly relax your SELinux policy ))
Updated by Erwin Mueller over 14 years ago
Hi, just installed Redmine 1.0.0 on Fedora 13 with SELinux disabled. I get the same error:
[Tue Aug 17 23:08:55 2010] [error] [client 192.168.0.40] /var/www/globalscalingsoftw\ are-projects.com/redmine/redmine-1.0.0/public/../config/../vendor/rails/railties/lib\ /rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprec\ ated and will be removed on or after August 2010. Use #requirement [Tue Aug 17 23:08:55 2010] [error] [client 192.168.0.40] [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] /usr/lib/ruby/gems/1.8/gems\ /rails-2.3.5/lib/dispatcher.rb:24: warning: already initialized constant Dispatcher [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] /var/www/globalscalingsoftw\ are-projects.com/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller\ /cgi_process.rb:22:in `__send__' [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] : [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] undefined method `env_table\ ' for nil:NilClass [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] ( [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] NoMethodError [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] ) [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] \tfrom /var/www/globalscali\ ngsoftware-projects.com/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_con\ troller/cgi_process.rb:22:in `dispatch_cgi' [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] \tfrom /var/www/globalscali\ ngsoftware-projects.com/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_con\ troller/dispatcher.rb:101:in `dispatch_cgi' [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] \tfrom /var/www/globalscali\ ngsoftware-projects.com/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_con\ troller/dispatcher.rb:27:in `dispatch' [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] \tfrom /var/www/globalscali\ ngsoftware-projects.com/redmine/redmine-1.0.0/public/dispatch.cgi:10 [Tue Aug 17 23:09:00 2010] [error] [client 192.168.0.40] Premature end of script hea\ ders: dispatch.cgi
Otherwise Redmine works fine. I think I will try this HOWTO: Setup Redmine through Apache using Mongrel Clusters http://ubuntuforums.org/showthread.php?t=674598 because it worked before on a different server.
Here are my ruby gems installed:
actionmailer (2.3.5) actionpack (2.3.5) activerecord (2.3.5) activeresource (2.3.5) activesupport (2.3.5) inifile (0.3.0) lockfile (1.4.3) net-ssh (2.0.23) rack (1.1.0, 1.0.1) rails (2.3.5) rake (0.8.7)
Updated by dj radon over 14 years ago
When I attempt to run dispatch.cgi I get:
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/cgi_process.rb:22:in `__send__': undefined method `env_table' for nil:NilClass (NoMethodError) from /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/cgi_process.rb:22:in `dispatch_cgi' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:27:in `dispatch' from ./dispatch.cgi:10
here are my local gems:
actionmailer (2.3.5, 2.1.1) actionpack (2.3.5, 2.1.1) activerecord (2.3.5, 2.1.1) activeresource (2.3.5, 2.1.1) activesupport (2.3.5, 2.1.1) fcgi (0.8.7) mysql (2.8.1) rack (1.0.1) rails (2.3.5, 2.1.1) rake (0.8.7, 0.8.2)
Updated by Charles Canato about 14 years ago
Felix, Steve, and others, thank you so much for trying to help. Unfortunately, even with the trunk version, it was not possible to run it under CGI on SLES-10.
Just providing the answers: yes, SLES-10 may run SELinux, but it's disabled by default, and that's the scenario I was trying to. As they have their AppArmor application, which have some similarities, I also disabled it. Nothing like that was able to let Redmine work under CGI.
You see, by what I've read, I wasn't really planning to run it under CGI. It just made sense to me that CGI was a good start, and once it was working in that mode, I could upgrade that to FastCGI, Fcgid, etc.
Anyway, by the end of the day: I just couldn't run it under CGI. Period. The Apache user was really finding the correct executables and versions, configuration seemed totally ok, and so.
As soon as I got tired, and tried FastCGI, it worked flawlessly. Then I changed it to fcgid. Running great right at this moment.
So, thank you very much guys. But getting Redmine (or even other Rails apps, I didn't try any others to be true) to run CGI at some scenarios is really a fight.
Obs.: I had a Debian server recently delivered to me... can't believe that, among a lot of problems to have Rails running, I had the very same problem with CGI. Immediately, I moved it to fcgid, and everything is going wonderful.
Once again, thank you guys, and sorry for having taken so much time to inform you on my progress.
Updated by Shack Dougall about 14 years ago
I'm having the same problem. I wonder if this could be part of the problem.
- Rails 2.3.2, Apache2 and CGI not working -- http://www.ruby-forum.com/topic/182327
The post talks about Rails 2.3.2, but there is also a comment that says "CGI support will be removed certainly in the next release, so don't waste your time trying to make it work."
Updated by Bruno Randolf about 14 years ago
I had the same problem under Ubuntu 10.04, and I was able to resolve it by changing the file public/.htaccess:
<IfModule mod_cgi.c> had to be changed to <IfModule mod_cgid.c>
Hope that helps!
Updated by Jayen Ashar over 13 years ago
Mirek Kratochvil wrote:
I tracked the problem to a point where it seems that cgi object that needs to be passed to rails/actionpack/lib/action_controller/cgi_process.rb:22 just isn't created somehow. Creating it manually in dispatch.cgi and passing it on, like this:
require 'cgi'
Dispatcher.dispatch(CGI.new)..moves the application a little further, but it then fails on some other error.
Thanks mk!
Updated by Jayen Ashar over 13 years ago
I was able to get redmine 1.2.0 working with cgi with the following patch to rails:
--- ../src/redmine-1.2.0/./vendor/rails/actionpack/lib/action_controller/cgi_process.rb 2011-05-31 02:53:34.000000000 +1000 +++ ./vendor/rails/actionpack/lib/action_controller/cgi_process.rb 2011-06-12 16:09:27.000000000 +1000 @@ -19,7 +19,7 @@ end def self.dispatch_cgi(app, cgi, out = $stdout) - env = cgi.__send__(:env_table) + env = cgi.__send__(:env_table).to_hash env.delete "HTTP_CONTENT_LENGTH" cgi.stdinput.extend ProperStream @@ -48,7 +48,7 @@ headers['Status'] = status.to_s - if headers.include?('Set-Cookie') + if headers.include?('Set-Cookie') and headers['Set-Cookie'] != nil headers['cookie'] = headers.delete('Set-Cookie').split("\n") end
and the following patch to ruby:
--- ../src/ruby-1.8.7-p334/lib/cgi.rb 2009-12-14 13:40:07.000000000 +1100 +++ ../lib/ruby/1.8/cgi.rb 2011-06-12 19:23:41.000000000 +1000 @@ -551,7 +551,7 @@ options["type"] = "text/html" end - if options.has_key?("charset") + if options.has_key?("charset") and options["charset"] != nil options["type"] += "; charset=" + options.delete("charset") end @@ -588,13 +588,19 @@ buf += "Connection: " + options.delete("connection") + EOL end - buf += "Content-Type: " + options.delete("type") + EOL + if options.has_key?("type") and options["type"] != nil + buf += "Content-Type: " + options.delete("type") + EOL + elsif options.has_key?("Content-Type") and options["Content-Type"] != nil + buf += "Content-Type: " + options.delete("Content-Type") + EOL + else + buf += "Content-Type: " + "text/plain" + EOL + end if options.has_key?("length") buf += "Content-Length: " + options.delete("length").to_s + EOL end - if options.has_key?("language") + if options.has_key?("language") and options["language"] != nil buf += "Content-Language: " + options.delete("language") + EOL end
Updated by Go MAEDA almost 9 years ago
- Status changed from Reopened to Closed
dispatch.cgi was removed in r9604 (Redmine 2.0) and Rails no longer supports CGI.
https://github.com/rails/rails/commit/4a3afe0b4f4193d8f35827c5550727f98c6b63e9