prograils / lit

rails i18n web interface
MIT License
298 stars 71 forks source link

Lit.init returns nil therefore installation process fails #124

Open eduarmreyes opened 5 years ago

eduarmreyes commented 5 years ago

I'm not sure if this is regarding the version of my development environment but I can't finish the installation process.

ruby --version ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-linux]

rails --version Rails 4.2.11

Error is

➜ bundle exec rails g lit:install
What's the authentication function, ie. :authenticate_user! : :authenticate_user!
What's the key value engine? ([hash] OR redis): hash
Skipping config/initializers/lit.rb creation, file already exists!
Running rake db:migrate
~/.rvm/gems/ruby-2.3.6/gems/lit-0.3.3/lib/generators/lit/install_generator.rb:57:in `clear_cache': undefined method `cache' for nil:NilClass (NoMethodError)
    from ~/.rvm/gems/ruby-2.3.6/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
    from ~/.rvm/gems/ruby-2.3.6/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
    from ~/.rvm/gems/ruby-2.3.6/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `block in invoke_all'
    from ~/.rvm/gems/ruby-2.3.6/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `each'
    from ~/.rvm/gems/ruby-2.3.6/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `map'
    from ~/.rvm/gems/ruby-2.3.6/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `invoke_all'
    from ~/.rvm/gems/ruby-2.3.6/gems/thor-0.20.3/lib/thor/group.rb:232:in `dispatch'
    from ~/.rvm/gems/ruby-2.3.6/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
    from ~/.rvm/gems/ruby-2.3.6/gems/railties-4.2.11/lib/rails/generators.rb:157:in `invoke'
    from ~/.rvm/gems/ruby-2.3.6/gems/railties-4.2.11/lib/rails/commands/generate.rb:13:in `<top (required)>'
    from ~/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
    from ~/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require'
    from ~/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency'
    from ~/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
    from ~/.rvm/gems/ruby-2.3.6/gems/railties-4.2.11/lib/rails/commands/commands_tasks.rb:123:in `require_command!'
    from ~/.rvm/gems/ruby-2.3.6/gems/railties-4.2.11/lib/rails/commands/commands_tasks.rb:130:in `generate_or_destroy'
    from ~/.rvm/gems/ruby-2.3.6/gems/railties-4.2.11/lib/rails/commands/commands_tasks.rb:50:in `generate'
    from ~/.rvm/gems/ruby-2.3.6/gems/railties-4.2.11/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from ~/.rvm/gems/ruby-2.3.6/gems/railties-4.2.11/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Error is raised in this line of code:

      def clear_cache
        Lit.init.cache.reset
      end

Rails console test

➜ rails c
Loading development environment (Rails 4.2.11)
[1] pry(main)> Lit.init
=> nil
colinramsay commented 5 years ago

I also see this on Rails 5.1. It did work once, then I needed to reinstall, and when I did so I saw this problem.

colinramsay commented 5 years ago

I partially resolved this. First time round the lit migrations failed to run. When I sorted that issue, I ran the install again twice and it all worked...

ysf commented 5 years ago

Here it seems to have to do with Lit:Locale.table_exists? although it exists in the database, it returns false, therefore Lit:init failes and hell breaks loose.

jhovad commented 3 years ago

There are new releases but this install problem still exist :-( ruby 2.7.1, rails 6.1.3

ralfclaassens commented 1 year ago

I ran into this issue as well. My solution was just to run rails db:migrate in order to make sure the Lit database tables exist. The reason that rails app does not warn to run the migrations is probably: https://github.com/prograils/lit/blob/dc11ab3415524d16a6dfe40b130a07248dc65f2b/lib/lit/engine.rb#L22