amber icon indicating copy to clipboard operation
amber copied to clipboard

Error: undefined method 'respond_with_status' for HTTP::Server::Response

Open PeterMozesMerl opened this issue 4 years ago • 4 comments

Description

I tried to peek into Amber but I could not make the project run.

19.3.0 Darwin Kernel Version 19.3.0: Thu Jan 9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64

I installed it from MacPorts. I ran into the issue a few days ago. Today, I reproduced it from scratch.

Steps to Reproduce

  $  sudo port install shards
  $  curl -L https://github.com/amberframework/amber/archive/stable.tar.gz | tar xz
  $  cd amber-stable/
  $  shards install
  $  mcedit Makefile # edited the install path prefix
  $  make install
  $  amber new pet-tracker
  $  cd pet-tracker/
  $  amber watch

09:34:06 Watch run  | (INFO) Building...
Showing last frame. Use --error-trace for full trace.

In lib/amber/src/amber/pipes/cors.cr:54:26

 54 | context.response.respond_with_status 403
                       ^------------------
Error: undefined method 'respond_with_status' for HTTP::Server::Response
09:34:17 Watch run  | (INFO) Compile time errors detected, exiting...

Versions

Latest Catalina, up to date MacPorts

I installed Amber from source as the port wanted to install postgresql10-server while I already have postgresql11-server installed from MacPorts.

PeterMozesMerl avatar Mar 13 '20 09:03 PeterMozesMerl

I guess it’s the Crystal version which is

Crystal 0.30.1 (2019-10-31)

in MacPorts.

PeterMozesMerl avatar Mar 13 '20 10:03 PeterMozesMerl

Run the corresponding Amber version with the Crystal version. I'd recommend using the latest of both.

On Fri, Mar 13, 2020, 3:20 AM PeterMozesMerl [email protected] wrote:

I guess it’s the Crystal version which is

Crystal 0.30.1 (2019-10-31)

in MacPorts.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/amberframework/amber/issues/1187#issuecomment-598651182, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA6NJDTFKDPT2YICFUF73DRHICIBANCNFSM4LG6SNTQ .

elorest avatar Mar 13 '20 12:03 elorest

I installed Crystal 0.33.0 from source.

Installing shards was a pain. If I compiled it with Crystal 0.33.0, then it was looking for some file in /opt/crystal. That directory doesn’t exist. Also, I didn’t find it in the source but the shards binary.

The compiled shards that came with the 0.33.0 compiled .tar.gz in the embedded/bin/ displayed the same error message.

Finally, I managed to compile it with the 0.30.1 Crystal that came from MacPorts. After I removed everything from MacPorts, it still worked. But as soon as I recompiled it with Crytal 0.33.0, it was looking for that file. So, I used the working binary.

However, this made Amber fail to build.

$ shards install
Resolving dependencies
Fetching https://github.com/luckyframework/shell-table.cr.git
Fetching https://github.com/amberframework/amber-router.git
Fetching https://github.com/drujensen/cli.git
Fetching https://github.com/elorest/compiled_license.git
Fetching https://github.com/jeromegn/kilt.git
Fetching https://github.com/TechMagister/liquid.cr.git
Fetching https://github.com/amberframework/micrate.git
Fetching https://github.com/will/crystal-pg.git
Fetching https://github.com/crystal-lang/crystal-mysql.git
Fetching https://github.com/crystal-lang/crystal-sqlite3.git
Fetching https://github.com/stefanwille/crystal-redis.git
Fetching https://github.com/jeromegn/slang.git
Fetching https://github.com/phoffer/inflector.cr.git
Fetching https://github.com/mosop/teeplate.git
Fetching https://github.com/crystal-loot/exception_page.git
Fetching https://github.com/veelenga/ameba.git
Fetching https://github.com/drujensen/optarg.git
Fetching https://github.com/mosop/string_inflection.git
Fetching https://github.com/crystal-lang/crystal-db.git
Fetching https://github.com/ysbaddaden/pool.git
Fetching https://github.com/drujensen/callback.git
Using amber_router (0.3.0)
Using cli (0.8.0)
Using compiled_license (0.1.3)
Using kilt (0.4.0)
Using liquid (0.3.2)
Using micrate (0.6.1)
Using pg (0.20.0)
Using mysql (0.10.0)
Using sqlite3 (0.15.0)
Using redis (2.5.3)
Using shell-table (0.9.2 at 078a04ea58ead5203bb435a3b5fff448ddabaeea)
Using slang (1.7.1)
Using inflector (0.1.8)
Using teeplate (0.8.0)
Using exception_page (0.1.4)
Using ameba (0.11.0)
Using optarg (0.7.0)
Using string_inflection (0.2.1)
Using db (0.8.0)
Using pool (0.2.3)
Using callback (0.7.1)
Writing shard.lock
$ shards build amber
Dependencies are satisfied
Building: amber
Error target amber failed to compile:
Showing last frame. Use --error-trace for full trace.

In src/amber/cli.cr:1:1

 1 | require "cli"
     ^
Error: can't find file 'cli'

If you're trying to require a shard:
- Did you remember to run `shards install`?
- Did you make sure you're running the compiler in the same directory as your shard.yml?

I spent a few hours on it. Now I will give it up for a while. Most likely, it’s not Amber but Crystal. It’s weird I can’t compile a working Shards with the Crystal version that compiled itself.

$ crystal -v
Crystal 0.33.0 [612825a53] (2020-03-13)

LLVM: 9.0.1
Default target: x86_64-apple-macosx

$ shards --version
Shards 0.9.0 [642cc5b] (2020-03-13)

Too bad, since Amber seems the only framework that could replace Rails for me.

PeterMozesMerl avatar Mar 13 '20 12:03 PeterMozesMerl

@PeterMozesMerl try to use brew version or docker. It works perfect for me.

OpakAlex avatar Jun 08 '20 15:06 OpakAlex