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

Issues running a Clojerl release #83

Closed
oubiwann opened this issue Jul 10, 2020 · 16 comments
Closed

Issues running a Clojerl release #83

oubiwann opened this issue Jul 10, 2020 · 16 comments

Comments

@oubiwann
Copy link
Contributor

This is a follow up to the discovery work that @jfacorro did here:

Basically, when I try to run a Clojerl application using the script resulting from rebar3 release (e.g., executing ./_build/default/rel/NAME/bin/NAME console), I get an error like the following:

=INFO REPORT==== 9-Jul-2020::20:45:14.018627 ===
    application: clojerl
    exited: {bad_return,
                {{clojerl_app,start,[normal,[]]},
                 {'EXIT',
                     {#{'__type__' => 'clojerl.Error',
                        message =>
                            <<"NO_SOURCE_FILE:?:?: Could not locate clojure.core.server.beam or clojure/core/server on code path.">>},
                      [{'clojure.core','load-lib',3,
                           [{file,
                                "/Users/oubiwann/lab/clojusc/port-examples/_build/default/lib/clojerl/src/clj/clojure/core.clje"},
                            {line,4588}]},
                       {'clojure.core','-load-libs/1-loop_858/4-0-',5,
                           [{file,
                                "/Users/oubiwann/lab/clojusc/port-examples/_build/default/lib/clojerl/src/clj/clojure/core.clje"},
                            {line,4622}]},
                       {clojerl_app,init,0,
                           [{file,
                                "/Users/oubiwann/lab/clojusc/port-examples/_build/default/lib/clojerl/src/erl/clojerl_app.erl"},
                            {line,42}]},
                       {clojerl_app,start,2,
                           [{file,
                                "/Users/oubiwann/lab/clojusc/port-examples/_build/default/lib/clojerl/src/erl/clojerl_app.erl"},
                            {line,18}]},
                       {application_master,start_it_old,4,
                           [{file,"application_master.erl"},{line,277}]}]}}}}
    type: permanent

As a sanity check, I was able to run this application from the Clojerl REPL just fine:

clje.user=> (application/ensure_all_started :ports)
:ok
clje.user=> (ports.echo/echo "hey, it's a thing")
"hey, it's a thing"

The one difference I can note between the issue above and what Juan was seeing (in the comments at the above links) is that my vm.args does have the -mode interactive line present. I confirmed that it was actually in build/default/rel/ports/releases/0.1.0/vm.arg, too.

@oubiwann
Copy link
Contributor Author

My kerl builds are old, so I'll update those and work back through some recent Erlang versions and see if I witness any different behaviour ...

@oubiwann
Copy link
Contributor Author

oubiwann commented Jul 10, 2020

On Erlang 22.3 it crashes with this error:

=INFO REPORT==== 10-Jul-2020::00:00:41.214853 ===
    application: ports
    exited: {bad_return,
                {{'ports.app',start,[normal,[]]},
                 {'EXIT',
                     {undef,
                         [{'ports.app',start,[normal,[]],[]},
                          {application_master,start_it_old,4,
                              [{file,"application_master.erl"},
                               {line,277}]}]}}}}
    type: permanent

I also tried removing the interactive mode from the vm.args and updated the release script to use interactive instead of embedded and that didn't seem to affect anything other than removing the warning log message

Update: This error is simply due to the fact that the .clje files hadn't been compiled and can thus be ignored.

@jfacorro
Copy link
Member

jfacorro commented Jul 10, 2020

@oubiwann Do you have a public repository that would allow to reproduce the behaviour?

I've been using the CODE_LOADING_MODE environment variable to set the mode to interactive when not setting the -mode through the vm.args: CODE_LOADING_MODE=interactive _build/default/rel/NAME/bin/NAME foreground.

@oubiwann
Copy link
Contributor Author

Just pushed the code here:

Since I can't test using the release script, I've been starting up the REPL (using make repl which gives me command history with rlwrap) and executing the following:

(application/ensure_all_started :ports)
(ports.echo/echo "hey, it's a thing")

Note that I currently have the log level set to debug, so you'll see more sent to stdout than you might be used to ;-)

@oubiwann
Copy link
Contributor Author

oubiwann commented Jul 10, 2020

So, I think that second error I pasted in the comment is actually a red herring: it seems that rebar3 compile doesn't trigger rebar3 clojerl compile; when I do the latter, that error no longer results (as one would expect, upon examining that error in more detail).

With that realization, I've re-tested with Erlang 23.0 and 22.3 and get the same error (the one pasted in the ticket description). Note that I couldn't get clojerl to run with my current rebar3 install on Erlang 20.3 or 21.3. (Maybe I need to compile rebar3 on a per-kerl install basis?)

Also: I pushed a couple of tweaks to that repo (there was a minor regression in the sys config file).

@oubiwann
Copy link
Contributor Author

Oh wait!!

I didn't add the ENV var CODE_LOADING_MODE to make run in the Makefile! That works!!!

(I was testing by manually editing files, which didn't work ... but I probably missed something.)

(ports@spacemac)1> 'ports.echo':echo("hey, it's a thing").
"hey, it's a thing"

I'm running with the release console option, which of course puts me into the Erlang Shell. I wonder what the best way to run the Clojerl REPL from a release would be ...?

jfacorro added a commit that referenced this issue Jul 10, 2020
[#83] Update .app files with modules before creating a release
@oubiwann
Copy link
Contributor Author

oubiwann commented Jul 10, 2020

Update: This comment has been converted to a ticket here: #85

In LFE, it's possible to switch from the Erlang shell to the LFE REPL by simply starting up the REPL. Is that something that Clojerl supports?

Ah, yes!

> 'clojure.main':main([<<"-r">>]).
Clojure 0.6.0
clje.user=> 

Looks like I can run a REPL directly if instead of doing this:

CODE_LOADING_MODE=interactive $(PROJ_BIN) console

I do this:

CODE_LOADING_MODE=interactive $(PROJ_BIN) start
$(PROJ_BIN) eval "'clojure.main':main([<<\"-r\">>])"
$(PROJ_BIN) attach;

@oubiwann
Copy link
Contributor Author

oubiwann commented Jul 10, 2020

Update: This comment has been converted to a ticket here: #86

Hrm, maybe more than just the call to main is needed, though.

If I make my test echo call:

clje.user=> (ports.echo/echo "hey, it's a thing")

I get this:

clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=> clje.user=>

If I switch to starting up a release console, and then start the Clojure REPL manually via an Erlang call, I see more of what's going on, getting this after making the echo call:

Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> ports.echo/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> orts.echo/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> rts.echo/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> ts.echo/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> s.echo/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> .echo/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> echo/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> cho/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> ho/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> o/echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> /echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> echo "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> cho "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> ho "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> o "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=>  "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> "hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> hey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> ey, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> y, it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> , it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=>  it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> it's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
clje.user=> t's a thing")
Couldn't unread to erlang.io.PushbackReader: :badargclje.user=> 
's a thing")
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg
Couldn't unread to erlang.io.PushbackReader: :badarg

clje.user=>  a thing")
clje.user=> a thing")
clje.user=>  thing")
clje.user=> thing")
clje.user=> hing")
clje.user=> ing")
clje.user=> ng")
clje.user=> g")
clje.user=> ")
clje.user=> )
clje.user=> 
clje.user=> 

@jfacorro
Copy link
Member

@oubiwann I merged #84 and built a release in the project you shared. The release is successfully starting now.

I'm attaching a screenshot with the minor changes I did to the Makefile and rebar.config.
Screenshot 2020-07-10 at 18 20 20

@jfacorro
Copy link
Member

In LFE, it's possible to switch from the Erlang shell to the LFE REPL by simply starting up the REPL. Is that something that Clojerl supports?

Ah, yes!

> 'clojure.main':main([<<"-r">>]).
Clojure 0.6.0
clje.user=> 

Looks like I can run a REPL directly if instead of doing this:

CODE_LOADING_MODE=interactive $(PROJ_BIN) console

I do this:

CODE_LOADING_MODE=interactive $(PROJ_BIN) start
$(PROJ_BIN) eval "'clojure.main':main([<<\"-r\">>])"
$(PROJ_BIN) attach;

That is a good point and a good thing to have. I would rather address this in a different issue though 😄.

Would it be possible for you to open a different issue for this? 🙏

@oubiwann
Copy link
Contributor Author

@jfacorro Absolutely!

Sorry, got into stream-of-consciousness mode ;-)

@oubiwann
Copy link
Contributor Author

I created two tickets for the above comments, and now will test the latest updates to the plugin (I might already have them, though -- I've been running the rebar3 clojerl plugin off of master for the past day ...)

@oubiwann
Copy link
Contributor Author

Hrm, looks like I'm running into a new problem with the latest plugin code in master:

If I don't compile the Clojerl code before I run a release, I get the same error I mentioned above ({'ports.app',start,[normal,[]]} undefined, etc.).

If I do compile first (which worked above), I now get an error:

===> Verifying dependencies...
===> Compiling clojerl
===> Compiling ports
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
          /Users/oubiwann/lab/clojusc/port-examples/_build/default/lib
          /Users/oubiwann/lab/clojusc/port-examples/apps
          /opt/erlang/23.0/lib
===> Resolved ports-0.1.0
===> Dev mode enabled, release will be symlinked
===> Errors generating release 
          Duplicated modules: 
        'erlang.io.IWriter' specified in clojerl and ports
        'erlang.io.IReader' specified in clojerl and ports
        'erlang.io.IPushbackReader' specified in clojerl and ports
        'erlang.io.ICloseable' specified in clojerl and ports
        'clojerl.IType' specified in clojerl and ports
        'clojerl.IStringable' specified in clojerl and ports
        'clojerl.ISequential' specified in clojerl and ports
        'clojerl.ISeqable' specified in clojerl and ports
        'clojerl.IReduce' specified in clojerl and ports
        'clojerl.IRecord' specified in clojerl and ports
        'clojerl.IMeta' specified in clojerl and ports
        'clojerl.IMap' specified in clojerl and ports
        'clojerl.ILookup' specified in clojerl and ports
        'clojerl.IHash' specified in clojerl and ports
        'clojerl.IEquiv' specified in clojerl and ports
        'clojerl.IDeref' specified in clojerl and ports
        'clojerl.ICounted' specified in clojerl and ports
        'clojerl.IColl' specified in clojerl and ports
        'clojerl.IAssociative' specified in clojerl and ports

But maybe I haven't updated my workflow to what it should be? Here's a sample set of tasks I do for a completely clean build:

  1. rebar3 clean
  2. rm -rf _build
  3. rebar3 clojerl compile
  4. rebar3 release <-- this is where it fails
  5. CODE_LOADING_MODE=interactive $(PROJ_BIN) console

@oubiwann
Copy link
Contributor Author

Ah! It works if I remove clojerl from my .app.src file :-)

I think we're good to close this issue!

@oubiwann
Copy link
Contributor Author

Thanks SO MUCH for all your help, Juan! ❤️

@jfacorro
Copy link
Member

No problem! I'm very happy to help if it means Clojerl is getting used 😄.

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