heroku - could not find a javascript runtime - angularjs

I am getting the following error message in the heroku logs when trying to access the application from the browser:
Gem Load Error is: Could not find a
JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
This is being triggered by a couple of gems - ngannotate-rails and coffee-rails.
This is a rails 4.2 application with a angular.js frontend, being deployed to heroku for the first time.
Heroku stack:
$ heroku stack
=== my_app Available Stacks
heroku-16
* cedar-14
Buildpacks:
$ heroku buildpacks
=== my_app Buildpack URLs
1. https://github.com/prakashmurthy/heroku-buildpack-nodejs
2. heroku/ruby
Both the node.js build and ruby build complete successfully.
PATH seems to be set correctly:
$ heroku run bash
Running bash on ⬢ my_app... up, run.1502 (Free)
~ $ echo $PATH
/app/bin:/app/vendor/bundle/bin:/app/vendor/bundle/ruby/2.3.0/bin:/usr/local/bin:/usr/bin:/bin
Appreciate any help in figuring out this issue.

Related

serve React build locally

I am currently learning React, to eventually pair with Ruby on Rails.
I am following the tutorial:
https://www.youtube.com/watch?v=w7ejDZ8SWv8
to get a handle on the language.
I have successfully compiled the build folder, running the command $ npm run build
I have also run the command $ sudo npm i -g serve in my terminal to install the npm serve
when running the build on localhost:8000, using the command $ serve - s -p 8000 in the terminal, it is serving using WEBrick::HTTPServer, throwing the following up in the terminal:
[2022-09-12 15:03:22] INFO WEBrick 1.7.0
[2022-09-12 15:03:22] INFO ruby 3.0.0 (2020-12-25) [x86_64-darwin19]
[2022-09-12 15:03:22] INFO WEBrick::HTTPServer#start: pid=5412 port=8000
which results in localhost:8000 showing:
My question:
Is there a way of altering this so I can serve my react build successfully, without causing issues when I go back to serving my RoR applications later?

Google App Engine goapp "deploy" works but "serve" fails, what's going on?

I started using Google App Engine today, so hopefully the answer will be obvious to someone with experience. After simply following this method to get App Engine interfacing with Cloud SQL, I'm having a frustrating issue: goapp deploy succeeds but goapp serve fails (using the cloud shell).
Here's the error:
XXXX#cloudshell:~/src/XXXX/app-engine (XXXX)$ goapp serve app.yaml
INFO 2018-06-21 07:29:08,115 devappserver2.py:764] Skipping SDK update check.
INFO 2018-06-21 07:29:08,235 api_server.py:268] Starting API server at: http://0.0.0.0:60628
INFO 2018-06-21 07:29:08,305 dispatcher.py:199] Starting module "default" running at: http://0.0.0.0:8080
INFO 2018-06-21 07:29:08,306 admin_server.py:116] Starting admin server at: http://0.0.0.0:8000
ERROR 2018-06-21 07:29:12,254 go_runtime.py:181] Failed to build Go application: (Executed command: /google/go_appengine/goroot/bin/go-app-builder -app_base /home/XXX/app-engine -arch 6 -dynamic -goroot /google/go_appengine/goroot -gopath /home/XXX/gopath:/google/gopath -nobuild_files ^^$ -incremental_re
build -unsafe -binary_name _go_app -extra_imports appengine_internal/init -work_dir /tmp/tmpT1RTRMappengine-go-bin -gcflags -I,/google/go_appengine/goroot/pkg/linux_amd64_appengine -l
dflags -L,/google/go_appengine/goroot/pkg/linux_amd64_appengine hello.go)
/home/XXX/gopath/src/github.com/go-sql-driver/mysql/connection.go:12: can't find import: "context"
2018/06/21 07:29:09 Can't find package "context" in $GOPATH: cannot find package "context" in any of:
/google/go_appengine/goroot/src/context (from $GOROOT)
/home/XXX/gopath/src/context (from $GOPATH)
/google/gopath/src/context
2018/06/21 07:29:12 go-app-builder: build timing: 0×skip (3ms total), 9×compile (2.731s total), 0×link (0 total)
2018/06/21 07:29:12 go-app-builder: failed running compile: exit status 2
I'm suspicious that the version of go being used is wrong. The stated version is 1.6.3 but as I understand "context" requires 1.7. Here's the relevant cloud shell output for that:
XXXX#cloudshell:~ (XXX)$ goapp version
go version go1.6.3 (appengine-1.9.48) linux/amd64
XXXX#cloudshell:~ (XXX)$ go version
go version go1.10 linux/amd64
However, despite my best efforts I have been unable to find any resources on how to manipulate the "goapp" go version.
My app.yaml includes:
runtime: go
api_version: go1.8
And goapp get yields this:
XXXX#cloudshell:~/src/XXX/app-engine (XXX)$ goapp get
package context: unrecognized import path "context" (import path does not begin with hostname)
The go file itself is an exact copy of the demo from the linked above.
As confirmed on a comment on the question the solution was using dev_appserver.py, instead of goapp serve.
goapp is the old tool to handle GAE tasks. Now it's recommended to use dev_appserver.py for the local development, and gcloud app commands for tasks in the cloud (e.g. gcloud app deploy instead of goapp deploy).
Note that goapp is not deprecated, but dev_appserver.py provides more flexibility on local dev, while gcloud app uses the properly documented and quite useful App Engine Admin API (unlike the older tools), making debugging a lot easier in case something goes wrong with your deployment.
In Google App Engine, if you need to get a context, you should probably use google.golang.org/appengine.NewContext() for a context during an HTTP request, or google.golang.org/appengine.BackgroundContext() if it's outside a request. Both return context.Context, which is the same that you would get by creating a context through the context package, but with a context prepared to be used within GAE.
This does not tell you why the imports are not working (other than goapp looks to be using 1.6), but will just work around the issue avoiding you to import any context package.

CLI 400 error deploying to Google App Engine

Today I got a new error when trying to deploy my application to Google App Engine via the command line:
Updating module [default]...-ERROR: (gcloud.preview.app.deploy) Server responded with code [400]:
Bad Request Unexpected HTTP status 400.
Your app may not have more than 120 versions.
Please delete one of the existing versions before trying to create a new version.
I am deploying to the top level using --promote, not creating other versions. How do I fix this error?
There is also a way to do this via command line if that interests you.
gcloud preview app versions list
gcloud preview app modules delete <module_name> --version=<version_number>
UPDATE 2017
(see also CLI 400 error deploying to Google App Engine
)
List all versions:
gcloud app versions list
Delete versions v1 and v2:
gcloud app versions delete v1 v2
https://cloud.google.com/sdk/gcloud/reference/app/versions/
So I found a way to do it through the web GUI (https://console.developers.google.com). If you go to the "App Engine" tab there is a "Versions" option. Click that and it will take you to a listing of versions. Apparently one is created each time you deploy with --promote in addition to one for each version you deploy. These can be selected and then there is a trash can to click on them to delete them.
While this is not the CLI solution I would have liked, it works.
The previous answer for the command line is deprecated now. The alternative is the following:
To list all versions:
gcloud app versions list
To delete a version:
gcloud app versions delete v1 v2
More info on: https://cloud.google.com/sdk/gcloud/reference/app/versions/delete
Hope it helps!
If someone is looking for cloudbuild.yaml changes for this then here is the sample YAML config file
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', '<dockerRepository>', '.' ]
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
- name: "gcr.io/cloud-builders/gcloud"
entrypoint: 'bash'
args:
- '-eEuo'
- 'pipefail'
- '-c'
- |-
gcloud app versions list --format="value(version.id)" --sort-by="~version.createTime" | tail -n +6 | xargs -r gcloud app versions delete --quiet
To remove the last version only for a specific service. Keep in mind you could have several services in the same GCP.
Fist get the service name
gcloud services list --available
and then, remove it
gcloud app versions list --format="value(version.id)" --sort-by="~version.createTime" --service=SERVICE_NAME | tail -n -1 | xargs gcloud app versions delete --quiet

Google cloud sdks doesn't start preview for Docker image Mac OS

My app.yaml
runtime: custom
vm: true
api_version: 1
health_check:
enable_health_check: False
Dockerfile
# Use the official go docker image built on debian.
FROM golang:1.5.1
# Grab the source code and add it to the workspace.
ADD . /go/
# Install revel and the revel CLI.
RUN go get github.com/revel/revel
RUN go get github.com/revel/cmd/revel
# Use the revel CLI to start up our application.
ENTRYPOINT revel run 4quorum-appengine dev 8080
# Open up the port where the app is running.
EXPOSE 8080
I was working through this article
http://jbeckwith.com/2015/05/08/docker-revel-appengine/
Preview
I am trying to preview it:
gcloud preview app run app.yaml --custom-entrypoint "revel run 4quorum-appengine dev 8080"
WARNING: The `app run` command is deprecated and will soon be removed.
Please use dev_appserver.py (in the same directory as the `gcloud` command) instead.
Module [default] found in file [/Users/802619/Projects/src/4quorum_root/app.yaml]
INFO: Looking for the Dockerfile in /Users/802619/Projects/src/4quorum_root
INFO: Using Dockerfile found in /Users/802619/Projects/src/4quorum_root
INFO 2015-11-06 18:03:44,226 application_configuration.py:399] No version specified. Generated version id: 20151106t180344
INFO 2015-11-06 18:03:44,226 devappserver2.py:763] Skipping SDK update check.
INFO 2015-11-06 18:03:44,266 api_server.py:205] Starting API server at: http://localhost:62780
INFO 2015-11-06 18:03:44,272 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO 2015-11-06 18:03:44,277 admin_server.py:116] Starting admin server at: http://localhost:8000
ERROR 2015-11-06 18:03:44,282 instance.py:280] [Errno 2] No such file or directory
The same thing if trying dev_appserver.py
Deploy
Deploy also doesn't work. Fails because of timeout.
gcloud preview app deploy ./app.yaml
WARNING: Soon, deployments will set the deployed version to receive all traffic by
default.
To keep the current behavior (where new deployments do not receive any traffic),
use the `--no-promote` flag or run the following command:
$ gcloud config set app/promote_by_default false
To adopt the new behavior early, use the `--promote` flag or run the following
command:
$ gcloud config set app/promote_by_default true
Either passing one of the new flags or setting one of these properties will
silence this message.
You are about to deploy the following modules:
- vaulted-gift-112113/default (from [/Users/802619/Projects/src/4quorum_root/app.yaml])
Deployed URL: [https://20151106t204027-dot-vaulted-gift- 112113.appspot.com]
(add --promote if you also want to make this module available from
[https://vaulted-gift-112113.appspot.com])
Beginning deployment...
Verifying that Managed VMs are enabled and ready.
Provisioning remote build service.
Copying certificates for secure access. You may be prompted to create an SSH keypair.
Building and pushing image for module [default]
Saving [.dockerignore] to [/Users/802619/Projects/src/4quorum_root].
----------------------------- DOCKER BUILD OUTPUT ------------------------------
Step 0 : FROM golang:1.5.1
---> f6271e8f3723
Step 1 : ADD . /go/
---> 94fafc5e8a30
Removing intermediate container cfbe197f6e93
Step 2 : RUN go get github.com/revel/revel
---> Running in d7ad8c923144
---> b65877cf3049
Removing intermediate container d7ad8c923144
Step 3 : RUN go get github.com/revel/cmd/revel
---> Running in 2a9b3320ce47
---> 428defd008f3
Removing intermediate container 2a9b3320ce47
Step 4 : ENTRYPOINT revel run 4quorum-appengine dev 8080
---> Running in 8b9e38ec69ec
---> 3749ee8a6636
Removing intermediate container 8b9e38ec69ec
Step 5 : EXPOSE 8080
---> Running in a0e6c66b56c8
---> dafff62b9643
Removing intermediate container a0e6c66b56c8
Successfully built dafff62b9643
--------------------------------------------------------------------------------
Copying files to Google Cloud Storage...
Synchronizing files to [gs://staging.vaulted-gift-112113.appspot.com/].
Updating module [default]...|Deleted [https://www.googleapis.com/compute/v1/projects/vaulted-gift- 112113/zones/us-central1-f/instances/gae-builder-vm-20151106t204027].
Updating module [default]...failed.
ERROR: (gcloud.preview.app.deploy) Error Response: [4] Timed out creating VMs.
About to drop this.
Moved to heroku. Google App Engine is not ready yet.

How can I debug a Dart AppEngine app

I'm now able to run a Dart app using
gcloud --verbosity debug preview app run app.yaml
and also to deploy and run on AppEngine
gcloud --verbosity debug preview app deploy app.yaml
but I haven't found a way to connect a debugger to the Dart app running on the development server.
I found http://dartbug.com/21067 but still couldn't find a way to make it work.
See also https://groups.google.com/a/dartlang.org/forum/#!topic/cloud/OK1nJtg7AjQ
Update 2015-02-27
The app can be run without Docker and then be debugged like any Dart command line application:
Source. https://groups.google.com/a/dartlang.org/d/msg/cloud/zrxgOHFz_lA/q5CdLLQPBAgJ
The API server is part of the App Engine SDK, and we are using it for
running tests in the appengine package. If you look at
https://github.com/dart-lang/appengine/blob/master/tool/run_tests.sh
you will see that it expects the environment variable
APPENGINE_API_SERVER.
The API server is in /platform/google_appengine/api_server.py
and takes a number of arguments. I just tested running it like this:
$ $CLOUD_SDK/platform/google_appengine/api_server.py \ -A
dev~test-application \ --api_port 4444 \ --high_replication \
--datastore_path /tmp/datastore
To run an app engine application outside the normal development server
requires that a number of environment variables are set. This worked
for my application:
$ GAE_LONG_APP_ID=test-application \ GAE_MODULE_NAME=default \
GAE_MODULE_VERSION=version \ GAE_PARTITION=dev \ API_PORT=4444 \
API_HOST=127.0.0.1 \ dart bin/server.dart
In the Dart Editor you cannot set environment variables for each
launch configuration, so they have to be set globally before starting
the Dart Editor. In WebStorm it is possible to have run configuration
specific environment variables.
This simple setup will of cause not support everything the normal
development server support. Some of the issues are:
Only one application at the time as it is always listening on port
8080 (can easily be made configurable) * The users API (mocking this
shouldn't be that difficult) * The modules API * No health-checks
(should not be a problem) * All HTTP headers are direct from the
client (no x-appengine- headers) * The admin web interface is not
available * Probably other stuff as well
This is all experimental, but it is one solution for a simpler
developer setup, which of cause does not match the deployment
environment as closely as the development server.
Running the API Server using Docker is also possible as the image
google/cloud-sdk with the Cloud SDK is on hub.docker.com.
Use the following Dockerfile
FROM google/cloud-sdk EXPOSE 4444 ENTRYPOINT
["/google-cloud-sdk/platform/google_appengine/api_server.py", \
"-A", "dev~test-application", \ "--api_port", "4444", \
"--high_replication", \ "--datastore_path", "/tmp/datastore"]
Build and run
$ docker build -t api_server . $ docker run -d -p 4444:4444 api_server
Change API_HOST above to 192.166.59.103 (of wherever your Docker
containers are) and run.
Regards, Søren Gjesse
Update 2014-11-27
Debugging from DartEditors debugger started working with the bleeding Dart build 1.8.0.edge_042017.
I assume that the next dev build (probably 1.9.0-dev1.0) will include the related fixes as well?
Detailed steps how this works can be found here: https://groups.google.com/a/dartlang.org/d/msg/cloud/OK1nJtg7AjQ/u-GzUDI-0VIJ
Build a custom Docker image with the latest Dart dev build 1.8.0-dev.4.6.
The Dart team is actually preparing an easy way to do this yourself (see https://github.com/dart-lang/dart_docker)
Installe the latest bleeding_edge on the host system (using this script https://gist.github.com/zoechi/d240f56a32ed5649797f or manual download from http://gsdview.appspot.com/dart-archive/channels/be/raw/latest/editor/darteditor-linux-x64.zip)
Add this to the app.yaml file
env_variables:
DBG_ENABLE: 'true'
# disable health-checking because this is so annoying during debugging
vm_health_check:
enable_health_check: False
See How to disable health checking for `gcloud preview app run` for more details about customizing health checking.
Launch the server code of your app with glcoud --verbosity debug app run app.yaml or glcoud --verbosity debug app run app.yaml index.yaml
Wait until the Docker container is ready (check with docker ps if the Command column shows a value starting with /dart_runtime/dart_
Open DartEditor
Open Menu Run > Remote Connection...
Connect to: Command-line VM
Host: localhost if you dont use boot2dockeror the IP address returned by the commandboot2docker ip`
Port: 5005
Select Folder... select the directory which contains the source code of your project.
Click OK
Set breakpoints and continue as usual.
Old
A first step is using the Observatory which includes a browser based debugger UI.
To make this work add the following lines to the app.yaml file
network:
forwarded_ports: ["8181"]
This might be useful as well to make the server.dart wait until we had the chance to set breakpoints using the observatory.
env_variables:
DART_VM_OPTIONS: '--pause-isolates-on-start'
boot2docker gives us the Docker ip (192.168.59.103) and after starting with gcloud preview app run app.yaml we can connect to http://192.168.59.103:8181 which should open the Observatory GUI.

Resources