Giter Club home page Giter Club logo

Comments (15)

ParsonsProjects avatar ParsonsProjects commented on July 18, 2024 4

Hello, I have had a similar issue when running cypress open locally on a windows machine. After some trial and error I narrowed it down to the setFilePermission function. It looks like the issue is that after opening and changing the file permissions the file stays open which locks other actions being performed on the given file.

This is a really quick fix adding closeSync to the end of the function to ensure that the file is closed to give other actions access to the files.

const setFilePermission = (dir, permission) => {
  try {
    if (fs.existsSync(dir)) {
      const fd = fs.openSync(dir, 'r')
      fs.fchmodSync(fd, permission)
      fs.closeSync(fd)
    }
  } catch (error) {
    // eslint-disable-next-line no-console
    console.log(error)
  }
}

from cypress-image-diff.

hai-le-niteco avatar hai-le-niteco commented on July 18, 2024 1

@bentleyvk we change the permission of the screenshot so the file can be copied/removed from one folder to the other. I think similar to this issue, there is some confiugration that will fail if we don't set the permission. I think if we copy only instead file permission is not necessary.

Do you have any plan of fixing this or any permanent workaround? I have to stay at 1.15.7 due to this issue.

from cypress-image-diff.

PippoRaimondi avatar PippoRaimondi commented on July 18, 2024 1

@bentleyvk we change the permission of the screenshot so the file can be copied/removed from one folder to the other. I think similar to this issue, there is some confiugration that will fail if we don't set the permission. I think if we copy only instead file permission is not necessary.

Do you have any plan of fixing this or any permanent workaround? I have to stay at 1.15.7 due to this issue.

yep, I am working on it! I will ask you guys to test it out for feedback soon though

from cypress-image-diff.

PippoRaimondi avatar PippoRaimondi commented on July 18, 2024 1

I am merging the above PR, it will generate a new version...try it out and let me know...

my understanding is that the failure is here:

  _fsExtra["default"].moveSync(originalFilePath, newFilePath, {
    overwrite: true
  });

so it could mean the the file within compared does not have the permission to be overwritten, so I am granting the most flexible file permission possible so any user could mess with it...

from cypress-image-diff.

bentleyvk avatar bentleyvk commented on July 18, 2024 1

@bentleyvk can you share more details?

  • where are you running the tests? locally, some remote desktop, docker etc..
  • which directory the tests are triggered?
  • what OS are you working on..

Before I can fix it I need to replicate it...

I am running locally on Windows 10 Version 20H2 using Docker Desktop with Use the WSL 2 based engine enabled (when it is disabled, tests seem to pass but sometimes I get the same permission error).
I have a monorepo with yarn workspaces.
I am starting tests using Node script that runs cypress in docker. Test command is triggered in root directory but scripts run in subrepo.

from cypress-image-diff.

fangmarks avatar fangmarks commented on July 18, 2024 1

Yup, adding that fixes it for me as well

from cypress-image-diff.

PippoRaimondi avatar PippoRaimondi commented on July 18, 2024 1

I will add the fix above, thanks so much for sharing @ParsonsProjects

from cypress-image-diff.

PippoRaimondi avatar PippoRaimondi commented on July 18, 2024

I will be having a look at this.

from cypress-image-diff.

bentleyvk avatar bentleyvk commented on July 18, 2024

I am having the same issue. If I understand correctly it appears only when running Docker Desktop with WSL flag enabled:
image
Because disabling this flag, tests passes.
Also, when I commented out (0, _utils.setFilePermission)(details.path, 511);, tests pass even with this flag on.
Here is more info about WSL and file permissions: https://docs.docker.com/desktop/windows/troubleshoot/#permissions-errors-on-data-directories-for-shared-volumes
Just curious why it is needed to change permissions to 511?

from cypress-image-diff.

PippoRaimondi avatar PippoRaimondi commented on July 18, 2024

@bentleyvk we change the permission of the screenshot so the file can be copied/removed from one folder to the other. I think similar to this issue, there is some confiugration that will fail if we don't set the permission. I think if we copy only instead file permission is not necessary.

from cypress-image-diff.

PippoRaimondi avatar PippoRaimondi commented on July 18, 2024

Can you guys test this out? I assume the problem is overwriting a permissionless file... so adding permission should workaround it:

#73

from cypress-image-diff.

bentleyvk avatar bentleyvk commented on July 18, 2024

I still get the same error Error: ENOENT: no such file or directory, open '/e2e/demo/cypress-visual-screenshots/comparison/PageLayoutDemo.spec.tsx-basic-3440x1440.png' 😕
I tried removing comparison folder before running tests but no luck.

from cypress-image-diff.

PippoRaimondi avatar PippoRaimondi commented on July 18, 2024

@bentleyvk can you share more details?

  • where are you running the tests? locally, some remote desktop, docker etc..
  • which directory the tests are triggered?
  • what OS are you working on..

Before I can fix it I need to replicate it...

from cypress-image-diff.

fangmarks avatar fangmarks commented on July 18, 2024

I still having this Error as well, I'll try the solution above and report back if it works in my case

from cypress-image-diff.

PippoRaimondi avatar PippoRaimondi commented on July 18, 2024

@ParsonsProjects fix has now been merged, thanks a lot for contributing team!

from cypress-image-diff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.