Giter Club home page Giter Club logo

Comments (5)

timriley avatar timriley commented on September 23, 2024

Hi @asilano, thank you for this report!

I've just tried to replicate this. Here's what I did:

(1) Create a brand new hanami app: hanami new my_app (using the 2.0.3 release).

(2) Update the Gemfile to the following, and then run bundle update

# frozen_string_literal: true

source "https://rubygems.org"

gem "hanami", github: "hanami/hanami", branch: "main"
gem "hanami-router", github: "hanami/router", branch: "main"
gem "hanami-controller", github: "hanami/controller", branch: "main"
gem "hanami-validations", github: "hanami/validations", branch: "main"

gem "dry-monads"
gem "dry-types", "~> 1.0", ">= 1.6.1"
gem "puma"
gem "rake"

group :development, :test do
  gem "dotenv"
end

group :cli, :development do
  gem "hanami-reloader", github: "hanami/reloader", branch: "main"
end

group :cli, :development, :test do
  gem "hanami-rspec", github: "hanami/rspec", branch: "main"
end

group :development do
  gem "guard-puma", "~> 0.8"
end

group :test do
  gem "rack-test"
end

(3) Enter the hanami console with bundle exec hanami console

(4) Access the Dry::Monads::Do constant, like your example. And for me, it seems to work fine:

~/src/scratch/my_app
❯ be hanami console
my_app[development]> require "dry-monads"
=> true
my_app[development]> Dry::Monads::Do
=> Dry::Monads::Do
my_app[development]>

I wonder if there's something different about your app or your environment that might be causing this issue?

Would you mind trying the steps I outlined above and seeing how you go?

Thanks!

from hanami.

asilano avatar asilano commented on September 23, 2024

Hey @timriley , thanks for taking a look. (Saw you at Brighton Ruby, btw - hence me kicking the hanami tyres a bit!)

Your sample app works fine. In fact, it also works if I change the hanami gems to be ~> 2.1.0.beta, so it doesn't even look like a version change is the cause. I'll go ahead and push my app - it's pretty small at the moment - and link it in here in case there's anything obvious that's up with it.

One thing that's interesting to me is that the fresh new app opens its console "quietly":

❯ be hanami console
my_app[development]>

...but when I launch the console on my app-in-progress, I get what looks like a pry location.

❯ bundle exec hanami c

From: /Users/chrishowlett/.gem/ruby/3.1.4/gems/hanami-cli-2.1.0.beta1/lib/hanami/cli/commands/app/console.rb:49 Hanami::CLI::Commands::App::Command::Environment#call:

    44:               err.puts "`#{engine}' is not bundled. Please run `bundle add #{engine}' and retry."
    45:               exit(1)
    46:             end
    47:
    48:             console_engine.start
 => 49:           end
    50:
    51:           private
    52:
    53:           def resolve_engine(engine, opts)
    54:             if engine

exalted[development]>

Is that expected?

from hanami.

asilano avatar asilano commented on September 23, 2024

Here's the repo where I'm having problems. https://github.com/asilano/hanami-exalted

from hanami.

timriley avatar timriley commented on September 23, 2024

Thanks for the extra detail, @asilano! And for sharing your app code too.

I just hopped in and took a look. Firstly, I was actually getting a crash inside pry when I was trying to run the console for the first time:

❯ be hanami console
bundler: failed to load command: hanami (/Users/tim/.local/share/rtx/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/bin/hanami)
/Users/tim/.local/share/rtx/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/pry-0.13.1/lib/pry/code.rb:342:in `<class:Code>': undefined method `=~' for class `Pry::Code' (NameError)

This looked to be something that was fixed in v0.14.0 of pry: pry/pry@b548784

So then I removed the version specified from the pry entry in your Gemfile and ran bundle update pry pry-byebug --conservative, which allowed the console to boot nicely:

❯ be hanami console
exalted[development]>

And just to double check, I confirmed that dry-monads seems to be fine here:

exalted[development]> require "dry/monads"
=> true
exalted[development]> Dry::Monads::Do
=> Dry::Monads::Do
exalted[development]>

Here's the git diff after this experiment:

diff --git a/Gemfile b/Gemfile
index dc126fc..95c65c3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -25,7 +25,7 @@ gem "oj"

 group :development, :test do
   gem "dotenv"
-  gem "pry", '~> 0.13.1'
+  gem "pry"
   gem "pry-byebug"
 end

diff --git a/Gemfile.lock b/Gemfile.lock
index cdedafa..1d1d559 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -187,7 +187,7 @@ GEM
       shellany (~> 0.0)
     oj (3.16.1)
     pg (1.5.4)
-    pry (0.13.1)
+    pry (0.14.2)
       coderay (~> 1.1)
       method_source (~> 1.0)
     pry-byebug (3.10.1)
@@ -281,7 +281,7 @@ DEPENDENCIES
   hanami-webconsole (~> 2.1.0.beta)
   oj
   pg
-  pry (~> 0.13.1)
+  pry
   pry-byebug
   puma
   rack-test

If you follow that pry upgrade, does your Hanami console look right again?

BTW, very happy to hear my Hanami words at Brighton Ruby encouraged you to take a look! ❤️ Hopefully we can get you over these few little hitches and can keep you moving again 😄

from hanami.

asilano avatar asilano commented on September 23, 2024

Hurrah, that sorts it out. An in turn points out that the similar looking error I was seeing on my web app was due to a different, and easily fixed, bug of my own writing. I am up and running again!

Now, I just need to re-pick-up what I was doing with these monads...

Thanks for your help!

from hanami.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.