I am unable to load env files located in a custom path using serverless framework.
The env files are kept in a folder 'config/environment' in the project and the files available are
.env
.env.dev
.env.qa
.env.prod
The contents of Serverless.yml are as below
plugins:
- serverless-dotenv-plugin
custom:
stage: ${opt:stage, "dev"}
dotenv:
basePath: ./config/environment/
logging: false
While triggering 'serverless deploy', I get error as below
Cannot resolve serverless.yml: Variables resolution errored with:
Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
It seems the .env files are not getting loaded and any help will be appreciated.
I have the same problem.
The problem happend when I update serverless framework v3 from v2.
If I don't use basePath or path and move .env, .env.prod to root folder it works, but I hope to have better solution.
Here
dotenv: {
path: 'config/${self:provider.stage}/.env',
},
Related
i have this code on my webpack.config.js file
const environment = process.env.ENVIRONMENT;
const uridb = `mongodb+srv://admin:admin#development-db.${process.env.URI}.mongodb.net/development?retryWrites=true&w=majority`
and inside my task definition you can see that the env do exist
but when i see the logs on my container i get undefined
MONGO_CONNECTION_STRING mongodb+srv://admin:admin#development-db.undefined.mongodb.net/development?retryWrites=true&w=majority
how do i make my envs reachable?
Your Webpack config file is something that is used at build time. Webpack is a build tool. You need to move that ${process.env.URI} environment variable lookup into your actual application code so that it can be resolved at run-time.
I opened an old Gatsby project on a new computer to try and complete, but when I tried to set up my development, I ran into this issue:
ERROR
Problems with gatsby-source-contentful plugin options:
spaceId: undefined - "spaceId" is required
accessToken: undefined - "accessToken" is required
host (default value): "cdn.contentful.com"
environment (default value): "master"
downloadLocal (default value): false
localeFilter (default value): [Function]
forceFullSync (default value): false
pageLimit (default value): 100
useNameForId (default value): true
not finished onPreInit - 0.030s
I did some research and saw this post which said they could run the development server but not the Gastby build. I updated my Contentful API key, my .env doc, and made sure the master environment was checked off but I'm still having this issue. Does anyone know what to do?
Here's my Github repo.
On your gatsby-config.js file, you oughta load the env vars
if your defined under the .env file the following snippit should work so your spaceID and accessToken aren't undefined.
At the begining of your gatsby-config.js add:
require("dotenv").config()
You can reference this
https://www.gatsbyjs.com/docs/how-to/local-development/environment-variables/
You need to set up the environment variables. Follow these steps:
Add the following snippet in your gatsby-config.js:
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
dotenv comes as a dependency of Gatsby so you don't need to install anything extra.
Once the snippet is in your gatsby-config.js, Gatsby will take your .env.development and .env.production when running gatsby develop and gatsby build respectively. Note that is the default behavior, you can customize the target environment file by changing the NODE_ENV variable or by setting a path in the snippet above
NODE_ENV is equal to development and production, that's why Gatsby takes each file in different commands.
Place your environment variables in both .env.development and .env.production files:
CONTENTFUL_ACCESS_TOKEN=yourAccessToken
CONTENTFUL_SPACE_ID=yourSpaceId
Target the environment variables while using the gatsby-source-contentful:
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
},
},
I have successfully installed Prince via the docker-compose.yml and I see the path + executable I need inside my workspace container but calling it out a number of ways in my Laravel .env will not find that path. In order to use prince I need to tell it where the PRINCE_EXECUTABLE_PATH is via the .env. What is the correct way to hit a directory in the workspace container from the Laravel app? I have tried to set a variable in the Laradock env and refer to it from laradock_workspace_1 and also just put the actual path in the env -- nothing seems to find it. What is the correct way?
I'm trying to automate the deployment of a Ruby on Rails app to App Engine using Cloud Build.
My app.yaml looked like this,
runtime: ruby
env: flex
entrypoint: bundle exec rails server
But I'm getting this error,
Step #1: ERROR: (gcloud.app.deploy) There is a cloudbuild.yaml in the current directory, and the runtime field in /workspace/app.yaml is currently set to [runtime: ruby]. To use your cloudbuild.yaml to build a custom runtime, set the runtime field to [runtime: custom]. To continue using the [ruby] runtime, please remove the cloudbuild.yaml from this directory.
Then I tried to change the runtime to custom and add a Dockerfile as custom runtime needs a Dockerfile.
But now I'm getting an error saying,
ERROR: (gcloud.app.deploy) A custom runtime must have exactly one of [Dockerfile] and [cloudbuild.yaml] in the source directory; [/home/milindu/Projects/ElePath-Ruby] contains both
Then I removed Dockerfile also. But now getting into this weird situation. You can see the 'Step #1:' is growing into several like stuck in a recursion.
Cloudbuild.yaml should work with App Engine Flexible without the need to use a custom runtime. As detailed in the first error message you received, you cannot have an app.yaml and the cloudbuild.yaml in the same directory if you are deploying in a non-custom runtime, to remedy the situation, follow these steps:
Move your app.yaml and other ruby files into a subdirectory (use your
original app.yaml, no need to use custom runtime)
Under your cloudbuild.yaml steps, modify the argument for app deploy
by adding a third one specifying your app.yaml's path.
Below is an example:
==================FROM:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy']
timeout: '1600s'
===================TO:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy', '[SUBDIRECTORY/app.yaml]']
timeout: '1600s'
I am working on open source LUA project. It has some modules and submodules. I am trying to set LUA_PATH env. But it always fails with error.
bash: ./user_modules/shared_testcases/?.lua: No such file or directory
Command I used is:
set LUA_PATH /usr/local/share/lua/5.2/?.lua;./user_modules/shared_testcases/?.lua
You need to quote the path:
set LUA_PATH '/usr/local/share/lua/5.2/?.lua;./user_modules/shared_testcases/?.lua'
Otherwise, as you have seen, the shell tries to expand the ?
in the path.