Issues with papercups OpenSource code

Hello! I’m using papercups project for my bachelors thesis analysis. This is my first experience with any elixir project. Does anyone know what versions of Elixir or Erlang I have to use in order to run it, for 2 straight days I’m getting error after error and I have no idea how to run it. Frontend is written there is Typescript so it works perfectly. Maybe there is sort of a tutorial how to set everything up correctly?

Thanks

The Dockerfile, .tool_versions, and elixir_buildpack.config all agree on 1.11.3 (with OTP 23, when specified).

Another thing you’ll definitely need to check into: what environment variables are needed? There are a bunch referenced in config/runtime.exs, but this line in dev.Dockerfile suggests that not all of them are required for building / compiling.

You’ll get more effective support if you’re more specific: what have you tried? What happened?

4 Likes

Hey! I’m back from a vacation, sorry for the long wait! I have downloaded elixir version 1.14 , because it was showing me this error, while I was on 1.11.3 - "warning: the archive phx_new-1.7.11 requires Elixir “~> 1.14” but you are running on v1.11.3
" After downloading version 1.14, my ecto migrate worked perfectly I was able to migrate my data, but now when running mix phx.server I’m getting bunch of errors about node_modules. I suppose the issue might be related to the version incompatibilities. I really want to make the server running, else I can’t make my research :confused: Maybe there is something you might advice me to do or we can hop into a discord call and try to fix the issue itself?

I’m not clear why you installed the latest phx_new - it’s only used when you run mix phx.new to start a totally-new Phoenix project. It’s not needed when you have an already-existing Phoenix project like papercups.

ANYWAYS

What errors? Especially for things like this related to the specific installed software versions, it’s practically impossible for other folks to reproduce what you can see right in front of you.

My guess (based solely on common things that happen with a newly-cloned project) is that you probably need to cd assets and then npm install. The note in assets/README.md about Node 14.5.0 is odd tho, since .tool_versions specifies 12…

2 Likes

Theoretically I may try to change the version of phx_new, then change my elixir version to 1.11.3. I suppose that there still might be some mismatches after making these changes. I changed my node version to 12.18.3, did npm install, but still no results after running mix phx.server

The errors I’ve encountered

./node_modules/theme-ui/dist/index.esm.jsAttempted import error: 'Context' is not exported from '@theme-ui/core'.

Unchecked runtime.lastError: The message port closed before a response was received.

index.js:1 ./node_modules/@monaco-editor/react/dist/index.mjs 136:62
Module parse failed: Unexpected token (136:62)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|   k(() => {
|     let i = Se.init();
>     return i.then(f => (c.current = f) && s(!1)).catch(f => f?.type !== "cancelation" && 
console.error("Monaco initialization: error:", f)), () => u.current ? I() : i.cancel();
|   }), l(() => {
|     if (u.current && c.current) {


index.js:1 ./node_modules/htmlparser2/lib/esm/index.js 51:9
Module parse failed: Unexpected token (51:9)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|  */
| 
> export * as ElementType from "domelementtype";
| import { getFeed } from "domutils";
| export { getFeed } from "domutils";

Both of these errors are caused by Node modules that use JS features not present in Webpack 4 - ?. syntax and export ... as. The affected versions were released after the shutdown date in the Papercups blog.

For monaco-editor, looks like you need a version prior to 0.31.0. Alternatively, you could try fiddling with your Webpack config as discussed on StackOverflow.

For htmlparser2, versions higher than 7 won’t compile on Webpack 4: Failed to Compile, with this error. · Issue #1237 · fb55/htmlparser2 · GitHub

2 Likes

Big thanks for the clarification, I just understood the one basic thing, that all of this we were talking about were frontend issues. Of course I have to take for granted them and I will try to fix them, but I will focus more on the backend as it’s my main goal for my thesis. I just opened localhost:4000 on which my phoenix server is running, I’ve encountered several issues again. It shows that I could not read file "./priv/static/index.html": no such file or directory, but in the papercups source code there isnt such a file at all, do I have to create it? Also have you tried to run papercups yourself, if so maybe there are some specifics that I should have in mind? I will add below all of the stuff that pops up when I open the backend server -

**`[info] GET /favicon.ico**
**[debug] Processing with ChatApiWeb.PageController.index/2**
**  Parameters: %{"path" => ["favicon.ico"]}**
**  Pipelines: [:browser]**
**[info] Sent 500 in 47ms**
**[error] #PID<0.1070.0> running ChatApiWeb.Endpoint (connection #PID<0.1059.0>, stream id 2) terminated**
**Server: localhost:4000 (http)**
**Request: GET /favicon.ico**
**** (exit) an exception was raised:**
    ** (File.Error) could not read file "./priv/static/index.html": no such file or directory
        (elixir 1.14.0) lib/file.ex:358: File.read!/1

        (chat_api 0.1.0) lib/chat_api_web/controllers/page_controller.ex:8: ChatApiWeb.PageController.index/2

        (chat_api 0.1.0) lib/chat_api_web/controllers/page_controller.ex:1: ChatApiWeb.PageController.action/2

        (chat_api 0.1.0) lib/chat_api_web/controllers/page_controller.ex:1: ChatApiWeb.PageController.phoenix_controller_pipeline/2

        (phoenix 1.5.5) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2

        (chat_api 0.1.0) lib/chat_api_web/endpoint.ex:1: ChatApiWeb.Endpoint.plug_builder_call/2

        (chat_api 0.1.0) lib/chat_api_web/endpoint.ex:4: anonymous fn/3 in ChatApiWeb.Endpoint."call (overridable 3)"/2

        (appsignal 2.1.7) lib/appsignal/instrumentation.ex:10: Appsignal.Instrumentation.instrument/1

        (chat_api 0.1.0) lib/chat_api_web/endpoint.ex:1: ChatApiWeb.Endpoint."call (overridable 4)"/2

        (chat_api 0.1.0) lib/plug/debugger.ex:136: ChatApiWeb.Endpoint."call (overridable 5)"/2

        (chat_api 0.1.0) lib/chat_api_web/endpoint.ex:1: ChatApiWeb.Endpoint."call (overridable 6)"/2

        (chat_api 0.1.0) lib/plug/error_handler.ex:65: ChatApiWeb.Endpoint.call/2

        (phoenix 1.5.5) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4

        (cowboy 2.8.0) c:/.././././bakalaurs/Elixir_Papercups/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2

        (cowboy 2.8.0) c:/.././././bakalaurs/Elixir_Papercups/deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3

        (cowboy 2.8.0) c:.././././bakalaurs/Elixir_Papercups/deps/cowboy/src/cowboy_stream_h.erl:291: :cowboy_stream_h.request_process/3

        (stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3`

Files in priv/static that aren’t checked into source control are typically generated by the project’s asset pipeline.

For instance, the postbuild script in papercups copies the build results to that directory:

Normally a request for /favicon.ico would find the file that was copied into priv/static and not get to PageController at all.

The original source for the file that PageController is crashing on is in assets/public/index.html

1 Like

Considering this issue, would you advice me to upgrade my Webpack to version 5, but I believe once I do that more incompatibilities might actually occur

I would not recommend upgrading MORE things to solve the problem of “some packages have been upgraded too much”, especially a major version of a tool as complicated as Webpack.

A good general rule when standing up “legacy” code like this is to match things as closely to what was available when the code worked (October 2021, for papercups).

IIRC there’s a way to force specific versions to be used in NPM, but I don’t recall the package.json incantation.

1 Like

Okay, thank you! I believe I will try to finish my current research about database integration, because at least there I can somehow make things work haha.

In the next days will try to use elixir/erlang/node versions that have been defined in the read me, but need to understand which version do I have to use 14.5.0 or 12… Maybe cloning the project from the beginning will solve some unnecessary issues that I’ve encountered during the compilation of the project. If I encounter some problems during the cloning, I will write them down here, but I have a small feeling that everything might work :smiley: