serverless / serverless/serverless

Unable to deploy a packaged service (This command can only be run in a Serverless service directory)

Open
#4,715 21 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat/packaging enhancement
Dominant language
JavaScript
Stars
46.9k
Forks
5.7k
Avg merge
10h 7m
Merged PRs (30d)
57

Description

This is a Bug Report

Description

  • What went wrong?
    I have created a vanilla aws-nodejs service.
    Then packaged and tried to deploy the artifacts outwith the source folder.

  • What did you expect should have happened?
    The stack should have been deployed to AWS

  • What was the config you used?

These are the steps to reproduce the issue from scratch

serverless create --template aws-nodejs --path hello-world
cd hello-world
serverless package --package artifacts
cd ..
serverless deploy --package hello-world/artifacts

The following error shows

  This command can only be run in a Serverless service directory
  • What stacktrace or error message from your provider did you see?
Error: This command can only be run in a Serverless service directory
    at getServerlessConfigFile.then (/usr/local/lib/node_modules/serverless/lib/plugins/lib/validate.js:20:23)
From previous event:
    at Deploy.validate (/usr/local/lib/node_modules/serverless/lib/plugins/lib/validate.js:12:51)

I've looked at the source file in the stack trace
gerServerlessConfigFile.js

and it seems to be looking for one of the standard config files

const jsonPath = path.join(servicePath, 'serverless.json');
  const ymlPath = path.join(servicePath, 'serverless.yml');
  const yamlPath = path.join(servicePath, 'serverless.yaml');
  const jsPath = path.join(servicePath, 'serverless.js');

  return BbPromise.props({
    json: fileExists(jsonPath),
    yml: fileExists(ymlPath),
    yaml: fileExists(yamlPath),
    js: fileExists(jsPath),

If I understand this correctly, the point of generating a package was not to rely on having access to the serverless config in source.
So I'd say that there is something with the way the deploy --package command

Similar or dependent issues:

  • #4692

Additional Data

  • Serverless Framework Version you're using: 1.26.0
  • Operating System: MacOs and Linux

thanks very much,

Jaume

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the commands in the issue, especially deploying with --package from the parent directory. Start with lib/utils/getServerlessConfigFile.js and lib/plugins/lib/validate.js, then trace how packaged deployment validation uses the service path. Done means the documented packaged service deploys successfully without the source directory present.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript
Domain
cli, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.