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

undefined method `translate' for I18n:Module #132

Closed
mikehaertl opened this issue Jul 27, 2013 · 14 comments
Closed

undefined method `translate' for I18n:Module #132

mikehaertl opened this issue Jul 27, 2013 · 14 comments

Comments

@mikehaertl
Copy link

I have a gollum wiki on my server. Since i also tried to install redmine, I now receive the following error when creating a new page in gollum:

undefined method `translate' for I18n:Module

In the stacktrace it shows, that the relevant call is in stringex:

/var/lib/gems/1.9.1/gems/stringex-2.0.5/lib/stringex/localization/backend/i18n.rb in i18n_translations_for
            ::I18n.translate("stringex", :locale => locale, :default => {})

I'm not a ruby expert, but from what i can tell, all requirements are met. Here's the output of gem list:

*** LOCAL GEMS ***

actionmailer (3.2.13)
actionpack (3.2.13)
activemodel (3.2.13)
activerecord (3.2.13)
activeresource (3.2.13)
activesupport (3.2.13)
arel (3.0.2)
builder (3.2.2, 3.0.0)
bundler (1.3.5)
charlock_holmes (0.6.9)
coderay (1.0.9)
diff-lcs (1.2.3)
erubis (2.7.0)
expression_parser (0.9.0)
github-markdown (0.5.3)
github-markup (0.7.5)
gollum (2.5.0, 2.4.15)
gollum-lib (1.0.4, 1.0.3)
grit (2.5.0)
hike (1.2.3)
hpricot (0.8.6)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.0.3)
json (1.8.0)
mail (2.5.4)
mime-types (1.23, 1.22)
mini_portile (0.5.1)
multi_json (1.7.7)
mustache (0.99.4)
net-ldap (0.3.1)
nokogiri (1.6.0, 1.5.9)
polyglot (0.3.3)
posix-spawn (0.3.6)
pygments.rb (0.5.2)
rack (1.5.2, 1.4.5)
rack-cache (1.2)
rack-openid (1.3.1)
rack-protection (1.5.0)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.13)
railties (3.2.13)
rake (10.1.0)
rdoc (3.12.2)
rmagick (2.13.2)
ruby-openid (2.2.3, 2.1.8)
sanitize (2.0.6, 2.0.3)
sinatra (1.4.2)
sprockets (2.2.2)
sqlite3 (1.3.7)
stringex (2.0.5, 1.5.1)
svn2git (2.2.2)
thor (0.18.1)
tilt (1.4.1, 1.3.7)
treetop (1.4.14)
tzinfo (0.3.37)
useragent (0.6.0)
wikicloth (0.8.0)
yajl-ruby (1.1.0)
yard (0.8.6.2)

Any idea, what could have caused this issue? Everything went fine before i messed around with redmine.

@rsl
Copy link
Owner

rsl commented Jul 29, 2013

can you run I18n.translate directly from a console within the app?

@mikehaertl
Copy link
Author

If you can tell me, how to do it, I'm more than happy to try. I'm not a ruby developer. All I did was trying to install redmine on the same server where I already had the gollum wiki running. I had problems to make redmine work with puma due to some conflicting version of rack. So I probably messed up things when i did gem install/gem uninstall different packages.

@rsl
Copy link
Owner

rsl commented Jul 29, 2013

from the command line, can you open rails console ? if so, try typing I18n.translate 'whatever'

@rsl
Copy link
Owner

rsl commented Jul 29, 2013

those bold things are commands to be typed in. tried bolding them but not sure that reads any better.

@mikehaertl
Copy link
Author

rails console does not work for me. It shows a help like:

Usage:
  rails new APP_PATH [options]

Options:
  -r, [--ruby=PATH]              # Path to the Ruby binary of your choice
                                 # Default: /usr/bin/ruby1.9.1
  -b, [--builder=BUILDER]        # Path to a application builder (can be a filesystem path or URL)

So it seems, the only command it understands is new, not console.

@rsl
Copy link
Owner

rsl commented Jul 29, 2013

try script/console. you are probably on an older version of rails for this application.

@mikehaertl
Copy link
Author

I assume you want me to go to the app directory of gollum, right? I actually think, that gollum is not a rails application at all. Have a look at the sources here:

https://github.com/gollum/gollum

@rsl
Copy link
Owner

rsl commented Jul 29, 2013

yeah i'm not familiar with gollum at all so can't do a whole lot other than point to some places to look. sorry my presumption this was a rails app was wrong lol. i take it your not using bundler or rvm gemsets or something like that?

@mikehaertl
Copy link
Author

I've used bundler to install redmine. But I've not used it for gollum. All i did here was gem install gollum.

I really don't know much about ruby, so all i can do is blind guessing. What's weird, is that i18n seems to be installed fine on my system. But how is this i18n module included? Is some require missing somewhere maybe?

I also see in your code, that you have another i18n module (if that's the right term for it). Could there maybe be some conflict here?

Sorry if all this sounds dumb - just trying to wrap my head around this ruby stuff. :)

@rsl
Copy link
Owner

rsl commented Jul 29, 2013

not a problem, man. our i18n module is namespaced though so it's not the issue. has something else in that stack defined a root-level i18n on the fly before i18n normal is loaded perhaps? i have no idea. it's clearly something in the new changes but not sure how to tell you to start investigating.

@mikehaertl
Copy link
Author

Thanks for your help. Unfortunately I'm not really sure, how i could check that. Here's the full stack trace, maybe you could have a look?

https://gist.github.com/mikehaertl/6110758

You said, it may be a problem with latest changes. I think i tried that, but gollum seems to be compatible even with newer version.

gollum-lib.gemspec:  s.add_dependency('stringex', '~> 2.0.5')

@rsl
Copy link
Owner

rsl commented Jul 31, 2013

it's not the gollum setup that's messed things up but something in changing your setup to accommodate redmine. if you use bundler you can avoid some of these cross-contaminations. the only guess i can make is that something defines the base-level module namespace I18n. stringex does not try to require it itself because that might not be what the user wants. we only check if it's [that is the module] defined.

i've added some code that ensures two things.

  1. i18n doesn't autoload if it isn't defined or doesn't respond to :translate
  2. i18n can't be directly assigned if it isn't defined or doesn't respond to :translate

2.0.8 gem has this functionality. try that and see the error you get.

@mikehaertl
Copy link
Author

Yay! It works again! Thanks a lot :).

FYI I did use bundler to install redmine. I'm not sure if bundler is meant to install required packages to the app directory instead of the system wide package directory. But from what i've seen i'd say, it just installs packages globally. So not sure how this helps to avoid conflicts with other app's dependencies. If you know some good introduction how to avoid conflicts with bundler i'd be happy to know.

Anyway, thanks again for your help.

@rsl
Copy link
Owner

rsl commented Aug 1, 2013

be aware you may not be using i18n though. part of what that code fixed is checking that i18n is defined with a translate method. your stack seems not to. so it's defaulting to the old internal backend. this shouldn't be a big issue or anything as long as you aren't trying to use the i18n backend.

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

2 participants