wozniakjan / erlcart

Erlang OpenShift2 Cartridge
Other
27 stars 12 forks source link

mix can't install hex on OpenShift #3

Closed wynst closed 7 years ago

wynst commented 8 years ago

I was trying to git push origin elixir project with the following mix.exs:

  defp deps do
    [{:slack, "~> 0.4.1"},
     {:websocket_client, git: "https://github.com/jeremyong/websocket_client"}]
  end

I got the following error:

remote:
remote: =PROGRESS REPORT==== 10-Feb-2016::13:25:06 ===
remote:          application: mix
remote:           started_at: nonode@nohost
remote: Could not find Hex, which is needed to build dependency :slack
remote: Shall I install Hex? [Yn] ** (Mix) Could not find an SCM for dependency :slack from Winston.Mixfile
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: deadbeef (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/deadbeef/erlang
remote: #<IO:0x00000001bc4278>
remote: #<IO:0x00000001bc4200>
remote: )
remote: Deployment completed with status: failure
remote: postreceive failed

Tried to manually install hex by logging in to openshift:

$ rhc ssh -a myapp
[myapp rhcloud.com myroot]\> export PATH=$OPENSHIFT_ERL_DIR/usr/bin/:$PATH
[myapp.rhcloud.com myroot]\> cd $OPENSHIFT_TMP_DIR
[myapp.rhcloud.com tmp]\> mix local.hex

......snip lengthy PROGRESS REPORT.....

=PROGRESS REPORT==== 13-Feb-2016::03:26:26 ===
          supervisor: {local,kernel_safe_sup}
             started: [{pid,<0.89.0>},
                       {id,inet_gethost_native_sup},
                       {mfargs,{inet_gethost_native,start_link,[]}},
                       {restart_type,temporary},
                       {shutdown,1000},
                       {child_type,worker}]
** (Mix) httpc request failed with: {:failed_connect, [{:to_address, {'s3.amazonaws.com', 80}}, {:inet, [:inet], :eacces}]}

Could not install Hex because Mix could not download metadata at http://s3.amazonaws.com/s3.hex.pm/installs/hex-1.x.csv.

full dump of log here



Any pointers is highly appreciated, thanks!

wozniakjan commented 8 years ago

Thank you for the bug report! Briefly scanning the issue it looks like the mix is trying to bind to a local port before getting the dependencies. Not sure what it is trying to accomplish, and binding to a port on OpenShift is a bit tricky, they are much more restricted. I will take a look this weekend if I can work around it somehow.

wynst commented 8 years ago

Thank you for responding!

I was trying to deploy this app to test the waters on Elixir/Erlang, apologize if I can't be of any help.

wozniakjan commented 8 years ago

some of the findings:

I hope to find some spare time next weekend to resolve the problem cause, then the fun part will be how to convince mix and elixir :)

bZichett commented 8 years ago

Any chance you can find some spare time to solve this issue? It would be very, very much appreciated.

wozniakjan commented 8 years ago

Great that you asked, I was running on a reduced schedule lately but I just started working on this again.

wozniakjan commented 8 years ago

Hi, I have finally advanced a bit, but the current situation is still far from optimal. I patched mix to bypass httpc and use wget instead, this seems to work quite well, mix local.hex fetches all that's needed and hex also works well as long as the dependencies are from git. Unfortunately, it fails for all other cases of dependency repositories, therefore, I recommend getting the dependencies on your machine and include them all in your project's git repository.

For the reference if anyone would like to help to resolve this issue: 1) the OpenShift limits network interfaces quite heavily 1.1) the $OPENSHIFT_ERL_IP can be bound and used to listen for incoming connections, the fw and routing tables will not let you send anywhere through this IP address 1.2) the 'ip addr' will give you the IP of ethernet interface used for outgoing connections. Binding that interface is forbidden by OpenShift, but for outgoing connections you generally shouldn't need to bind the socket to an address. 2) erlangs httpc module insists on binding a network interface in order to connect to some remote socket, I couldn't find a way around that 3) I have forked the elixir to https://github.com/wozniakjan/elixir, patched the mix to bypass httpc to avoid binding an interface. Cmdline utility wget downloads the file, mix reads the file from the disk and then proceeds 4) hex was a bit tough cookie for me to chew on

I recommend for now to work around the hex, download the dependencies and put them all to your project depository, rest of elixir environment seems to be working well, even if a bit slow and may need to execute some commands manually a few times. I managed to get phoenix running with a few additional tweaks around OpenShift hard timeouts and fact, that elixir doesn't have the fastest compiler. Unless I get enlightened by some fantastic idea or help from someone more knowledgeable, I will pause my research for some time and cowardly wait for OpenShift3, which could resolve all our issues after all.

valentin-fischer commented 7 years ago

Hi,

It seems openshift3 is out! I've tried to deploy an app from your config but it's failing unfortunately

The error is something like -> Resource kind not specified ...

wozniakjan commented 7 years ago

Hi, openshift2 and openshift3 are not backward compatible, unfortunately. For openshift3, try playing around with https://github.com/bitwalker/s2i-erlang

I will try to revisit and port this to openshift3 as well at some point in future