Amplify-cli: Multi-env OS team workflow directory paths bug

Created on 27 Aug 2019  Â·  11Comments  Â·  Source: aws-amplify/amplify-cli

Describe the bug
When _creating an amplify project & resource in Windows OS_ then pulling and working on the same Amplify project in a unix environment, directories have a problem with backslash and forward slashes. Cases where I've encountered this:

  • Amplify API mocking (cannot find schema.graphql)
  • Amplify push (can't generate graphql folder when in unix env due to incorrect directory)

To Reproduce
Steps to reproduce the behavior:

  1. Create an Amplify project in Windows OS
  2. Add a gql API resource
  3. clone and init project in a unix environment
  4. Make change to schema and push to amplify backend
  5. will not generate graphql/ folder
  6. Try to mock the API in a unix env (MacOS or Linux)
  7. Cannot mock cause it can't find directory
    2019-08-27T01:53:04.990Z - error: uncaughtException: ENOENT: no such file or directory, open '/home/*****/work/****/amplify\backend\api\****\build\schema.graphql'

Expected behavior
Amplify should be handling paths to directories between unix-based and Windows OS

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • Windows 10
  • MacOS High Sierra
  • Ubuntu 19.04

Additional context
I've already opened a previous issue on this but it was closed even without fixing the issue (thanks for that) #1522

bug code-gen mock platform

All 11 comments

This is not just a mock issue, it renders all of Amplify's commands (push, pull, init, etc.) completely broken on my machine

I'm having this same issue on these same systems. I have switched from mac to windows before with no issue. I had actually created the project on mac os, then worked on it in Windows, and am finally coming home to Ubuntu.

The GQL compile aspect might be a red-herring, it is also occurring with function and storage resources.

It also occurs with all amplify commands, from amplify status to amplify pull --restore, so the issue is actually worse than just preventing mocking. I can't push or update code. It's a completely debilitating bug and I can't work on the Amplify portion of my code on my new laptop until this bug is resolved

@ajhool what version are you using? We're currently stuck @ v1.11.0 due to some other bug in v1.12.0 and pushing and pulling is working fine for us. You might want to consider switching amplify version in the meantime.

I was using 2.0.0 but dropped down to v1.11.0 and the problem is still there. Specifically, it can't find a binary in the uuid node_modules by my function code

@ajhool Do you see an amplify/backend/function/<function-name>/node_modules directory?
if not, an you run amplify function build to build the node_modules for your function to test it locally?

@kaustavghosh06

That did not resolve the problem although it did point me in a potentially helpful direction

$:~/Development/myapp$ amplify --version
1.11.0
$:~/Development/myapp$ amplify function build
? Are you sure you want to continue building the resources? Yes
â ‹ Building resources. This may take a few minutes...[Error: ENOENT: no such file or directory, stat '/user/Development/myapp/amplify/#current-cloud-backend/storage/mystorage'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/user/Development/myapp/amplify/#current-cloud-backend/storage/mystorage'
}
✖ An error occurred when building the resources.
Error: ENOENT: no such file or directory, stat '/user/Development/myapp/amplify/#current-cloud-backend/storage/mystorage'

Whenever I try amplify init or amplify env pull --restore, Amplify is downloading the #current-cloud-backend into a .temp folder and then trying to build the functions. I think there might be an error when amplify is trying to install my node_modules -- I had a typescript config flag that might be part of the issue.

I also still see an amplify/.temp folder. This is the output when I run amplify init:

Initializing your environment: alpha2019-08-29T00:20:03.850Z - error: uncaughtException: ENOENT: no such f
ile or directory, stat '/user/Development/myapp/amplify/.temp/#current-cloud-backend/function/myfunction/src/node_modules/.bin/uuid

So, I can go into .temp/#current-cloud-backend/function/myfunction/src and run yarn install and it correctly installs all of my dependencies. Then, I can return to the root of my project and amplify init works successfully. However, when I attempt to run amplify push (the first thing that I'm attempting to do is delete the functions -- I'm not actually using them), the "Operation" shows that my Auth, Api, and Storage Categories are all in the "Create" mode, when they should just be No Change.

@ajhool whats the root of your project? Is it /user/Development/myapp?

Also, did you just copy/paste the file contents or use git to push/pull the files?
Can you make sure the project directory is correct in ampify/.config/project-config.json and set to your cwd?

@ajhool whats the root of your project? Is it /user/Development/myapp?

Yes. the actual path on my computer is slightly longer so I abbreviated it to that when posting -- if the path is inconsistent in some of my post, I probably made a substitution error.

Also, did you just copy/paste the file contents or use git to push/pull the files?
Can you make sure the project directory is correct in ampify/.config/project-config.json and set to your cwd?

I'm using git with these amplify files in .gitignore:

amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/backend/amplify-meta.json

I don't see a project path in project.config:

{
    "projectName": "[redacted]",
    "javascript": {
        "framework": "react",
        "config": {
            "SourceDir": "src",
            "DistributionDir": "build",
            "BuildCommand": "yarn build",
            "StartCommand": "yarn start"
        }
    },
    "providers": [
        "awscloudformation"
    ],
    "frontend": "javascript",
    "version": "1.0"
}

although my local-env-info.json looks good:

{
    "projectPath": "/user/Development/myapp",
    "defaultEditor": "code",
    "envName": "alpha"
}

and local-aws-info.json

{
    "alpha": {
        "configLevel": "project",
        "useProfile": true,
        "profileName": "default"
    }
}

I can also create a separate issue for this as not to trample over @nino-moreton 's issue which appears to isolate a path difference

@ajhool lets track this in a new issue

@yuth one last thought before jumping to new issue, if my status looks like:

| Category  | Resource name           | Operation | Provider plugin   |
| --------- | ----------------------- | --------- | ----------------- |
| Auth      | customer          | Create    | awscloudformation |
| Api       | customerapi          | Create    | awscloudformation |
| Storage   | customerstorage   | Create    | awscloudformation |
| Analytics | customeranalytics | Create    | awscloudformation |
| Function  | myFunctionA           | Delete    | awscloudformation |
| Function  | myFunctoinB   | Delete    | awscloudformation |

and I run amplify function push should that delete the desired functions and potentially resolve this issue? Is there any potential harm from running that command?

Edit: ah, it appears the harm of that command is that it deleted my entire stack, S3 bucket, dynamo tables, cognito table, etc. Anyways, I've moved onto a new env and that's solved my problem for now

I had this (or similar issue).
I think It was because of .graphqlconfig.yml which was added to the git repo on a window machine, and then I got the same one my mac. Because of it, the codegen was using the wrong slash.

Was this page helpful?
0 / 5 - 0 ratings