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

Command line arguments are ignored when using environment in plugins initialization. #960

Closed
Sickphilosopher opened this Issue Nov 2, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@Sickphilosopher
Copy link

Sickphilosopher commented Nov 2, 2018

We using plugin:

group :plugins do
  gem 'hanami-webpack', git: 'https://github.com/Sickphilosopher/hanami-webpack.git'
end

Plugin calls Hanami.env when loaded. (https://github.com/Sickphilosopher/hanami-webpack/blob/aab739d1a92eacc573c1b1232483c359dfcff1b1/lib/hanami/webpack.rb#L7)

We run 'hanami s -p 3000'
Expected: server starts with port 3000
Actual: server starts with the standard port 2300

When we call Hanami.env, the Components ['environment'] is filled and when it is reinitialized in command#call it is not overwritten.
And when we call environment in server.rb, it's default one.

environment.object_id:

"in hanami.rb (.env):"
46925592240600
"in command (.call):"
46925595649520
"in server (._ extract_options)"
46925592240600

Gemfile.lock: https://gist.github.com/Sickphilosopher/352c93102b4cc0a8b3f1590d5abb273f

@AlfonsoUceda

This comment has been minimized.

Copy link
Member

AlfonsoUceda commented Dec 16, 2018

Hi @Sickphilosopher can you tell us how we can reproduce this? I've tested in a fresh hanami app (v1.3.0) and it works fine, my steps:

  • Create a fresh hanami app
  • Generate binstubs for hanami command.
  • Add hanami-webpack to application's Gemfile as a plugin:
group :plugins do
  gem 'hanami-webpack', git: 'https://github.com/Sickphilosopher/hanami-webpack.git'
end
  • Follow steps 3 and 4 from hanami-webpack's README
3. Copy the base Webpack config webpack.config.sample.js and package.sample.json on your app root (removing the .sample in the name).
4. Run npm install.
  • Run bundle exec hanami s and I see port 2300
  • Run bundle exec hanami s -p 3000 and I see port 3000
@Sickphilosopher

This comment has been minimized.

Copy link

Sickphilosopher commented Dec 18, 2018

Hi, @AlfonsoUceda, i updated hanami-webpack and now it works as expected. But i wrote some hacks for this.
You can install old version and reproduce issue.

group :plugins do
  gem 'hanami-webpack', git: 'https://github.com/Sickphilosopher/hanami-webpack.git', ref: 'aab739d1a92eacc573c1b1232483c359dfcff1b1'
end

This should works.
Also your may not to do steps from hanami-webpack's readme, because hanami-webpack doesn't do anything on bundle hanami s.

@jodosha

This comment has been minimized.

Copy link
Member

jodosha commented Jan 9, 2019

@Sickphilosopher I'm sorry about this problem, can you please point me to the specific "hacks" that you used to make it to work again? Thanks.

@jodosha jodosha closed this Jan 9, 2019

@Sickphilosopher

This comment has been minimized.

Copy link

Sickphilosopher commented Jan 10, 2019

I removed all Hanami.env usages in plugin loading.
Sickphilosopher/hanami-webpack@9aec4be#diff-6ccfbf5179c6d08450f71fcea3b81516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment