cypress: Can't run Cypress test because of plugins error - Error: ENOENT: no such file or directory, stat '/.VolumeIcon.icns
Current behavior
After we installed and configured Typescript to Cypress:
On open cypress
and then starting a test, the browser opens and starts loading the test, but before the test actually starts, Cypress crashes and shows this error:
The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (/Users/maaike/Projects/cypress/cypress/plugins/index.ts)
Error: ENOENT: no such file or directory, stat '/.VolumeIcon.icns'
Desired behavior
With our current configurations we expect Cypress with Typescript added to work. We followed the instructions, then cleared cache, reinstalled cypress, but nothing helps. We searched on the shown error but can’t find anything useful. That’s why we think there might be a bug here. I hope you can investigate it and find the cause
Test code to reproduce
tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"lib": ["es6", "dom"],
"types": ["cypress", "node"],
"esModuleInterop": true,
"allowJs": true
},
"include": ["**/*.ts"]
}
cypress/plugins/index.ts:
// promisified fs module
import fs from 'fs-extra'
import path from 'path'
import webpack from '@cypress/webpack-preprocessor'
function getConfigurationByFile(file) {
const pathToConfigFile = path.resolve('cypress', 'config', `${file}.json`)
return fs.readJson(pathToConfigFile)
}
// plugins file
module.exports = (on, config) => {
require('cypress-terminal-report/src/installLogsPrinter')(on)
require('cypress-log-to-output').install(on, (type, event) => {
return (event.level === 'error' || event.type === 'error') && islogableError(event)
})
const options = {
// send in the options from your webpack.config.js, so it works the same
// as your app's code
webpackOptions: require('../../webpack.config'),
watchOptions: {},
}
on('file:preprocessor', webpack(options))
const environment = process.env.ENVIRONMENT || config.env.ENVIRONMENT || 'acceptance'
console.log(`plugins/index.ts: Loading local config from cypress/config/${environment}.json...`)
return getConfigurationByFile(environment)
}
webpack.config.js
const path = require('path')
module.exports = {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
}
Versions
Cypress 5.3.0
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 6
- Comments: 26 (4 by maintainers)
The solution to this issue is seriously to run
sudo touch /.VolumeIcon.icns
?As a workaround I ran
sudo touch /.VolumeIcon.icns
which isn’t ideal obviously but it should unblock you hopefullyWhat is causing this though?
Why is this closed?
@MaaikeFox Would you mind reopening this? Cypress shouldn’t be touching anything in that directory, so this still seems like a bug.
From my use case, this bug appears to be related to import resolution. When I import a file using an absolute path like
support/utils
, it throws the error. However, if I do a relative import like../support/utils
it works fine. Perhaps cypress is ignoring thebaseUrl
intsconfig.json
?From what I could find, seems like
.VolumeIcon.icns
, a file located at root dir/
on Mac, is used to store icon resources. It is a symlink toSystem/Volumes/Data/.VolumeIcon.icns
(runls -la
) and was missing after I upgraded my Mac OS. I created it and linked it back.Not sure how Cypress is using it. The file is still at zero bytes after running Cypress.
After dodging the
VolumeIcon.icns
error with thesudo touch /.VolumeIcon.icns
hack I am now getting this and it just gets more and more confusingOK, this works
sudo touch /.VolumeIcon.icns
, but will it crash in CI?I just ran into this and I was able to find the offending code by looking at the console. For me it was similar to @adarnon’s issue where I was trying to import something that I no longer had as a dependency.
I’m not sure this will help all of you guys, but for me what solved the problem is the following.
I had already installed the following deps, because I want to use cucumber as well along with cypress, the config is the usual as per the docs. Deps:
I was getting an error when I was starting my tests, so I found that I need latest
ts-loader
andwebpack
to I can continue go on. (This might solve the issue described here, what I think is that cypress uses indirectly throughts-loader
thisVolumeIcon
etc.)Get latest ts loader and webpack
But yet again another problem came up, NodeJS built-ins are not included by default, so we need to add them manually. If you are using somewhere NodeJS globals like process you might get in trouble. I my case I had to include path and process, so the way to do that is:
Adding Polyfills
"process": "0.11.10"
"path-browserify": "1.0.1"
Configure path
Configure process global var
Hope this might help some of you.
Attaching refs to my sources 📚 https://github.com/vfile/vfile/issues/38#issuecomment-532851965 https://webpack.js.org/migrate/5/ https://webpack.js.org/configuration/resolve/ https://stackoverflow.com/questions/65018431/webpack-5-uncaught-referenceerror-process-is-not-defined
I had this same problem, and @distinctdan 's comment helped me overcome it. I accidentally added a following import to one of my files (vscode autoimport):
Removing it solved the issue. It still doesn’t indicate what the problem originates exactly, but if you’re struggling with it, taking a look at your imports could help.
I also encountered this bug. Even though the message says it was a problem loading
plugins
, the cause in my case was that one of my commands (undersupport
) importedfs
. I assume that since commands run in the browser they can’t importfs
and somehow it propagates to this cryptic error message.