Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The specified icon 'extension/icon.png' wasn't found in the extension. #341

Closed
true0r opened this issue Apr 17, 2019 · 13 comments
Closed

The specified icon 'extension/icon.png' wasn't found in the extension. #341

true0r opened this issue Apr 17, 2019 · 13 comments
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities

Comments

@true0r
Copy link

true0r commented Apr 17, 2019

I use snap for install node on Ubuntu 19.04. This causes a problem that I found only when debugging because the error message leads to a false way.

This issue concerns node.js and there the question has already been raised and left unanswered (nodesource/distributions#663). It is necessary providing a true error message to save time for those who have this problem.

$ vsce package

 ERROR  The specified icon 'extension/icon.png' wasn't found in the extension.

Below code is never called.

vscode-vsce/src/package.ts

Lines 526 to 534 in f4a3d0d

onFile(file: IFile): Promise<IFile> {
const normalizedPath = util.normalize(file.path);
if (normalizedPath === this.icon) {
this.didFindIcon = true;
this.assets.push({ type: 'Microsoft.VisualStudio.Services.Icons.Default', path: normalizedPath });
this.vsix.icon = this.icon;
}
return Promise.resolve(file);
}

Call child_process.exec("only snap package") returns stdout and stderr as empty strings without error.

vscode-vsce/src/npm.ts

Lines 55 to 61 in f4a3d0d

function getNpmDependencies(cwd: string): Promise<string[]> {
return checkNPM()
.then(() => exec('npm list --production --parseable --depth=99999', { cwd, maxBuffer: 5000 * 1024 }))
.then(({ stdout }) => stdout
.split(/[\r\n]/)
.filter(dir => path.isAbsolute(dir)));
}

Call collectAllFiles() returns empty array.

vscode-vsce/src/package.ts

Lines 722 to 733 in f4a3d0d

function collectAllFiles(cwd: string, useYarn = false, dependencyEntryPoints?: string[]): Promise<string[]> {
return getDependencies(cwd, useYarn, dependencyEntryPoints).then(deps => {
const promises: Promise<string[]>[] = deps.map(dep => {
return glob('**', { cwd: dep, nodir: true, dot: true, ignore: 'node_modules/**' })
.then(files => files
.map(f => path.relative(cwd, path.join(dep, f)))
.map(f => f.replace(/\\/g, '/')));
});
return Promise.all(promises).then(util.flatten);
});
}

Call processor.onFile() will not happen.
const processedFiles = files.map(file => util.chain(file, processors, (file, processor) => processor.onFile(file)));

Similar issue #233.

@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities labels May 2, 2019
@joaomoreno joaomoreno added this to the Backlog milestone May 2, 2019
@joaomoreno joaomoreno removed this from the Backlog milestone Oct 11, 2019
@xontab
Copy link
Contributor

xontab commented Dec 29, 2019

I encountered the same issue ... The Snap version of NodeJS does not output the stdout when the following commands are used

cp.exec("npm....
cp.exec("node....
cp.exec("yarn....

Thus I managed to find a workaround by redirecting the output via echo (attached patch below). However this workaround is not compatible with other systems and operating systems.

diff --git a/src/npm.ts b/src/npm.ts
index 6137a3c..456c111 100644
--- a/src/npm.ts
+++ b/src/npm.ts
@@ -23,7 +23,8 @@ function exec(command: string, options: IOptions = {}, cancellationToken?: Cance
        return new Promise((c, e) => {
                let disposeCancellationListener: Function = null;
 
-               const child = cp.exec(command, { ...options, encoding: 'utf8' } as any, (err, stdout: string, stderr: string) => {
+               // Added echo as a workaround for snap nodejs support
+               const child = cp.exec(`echo $(${command})`, { ...options, encoding: 'utf8' } as any, (err, stdout: string, stderr: string) => {
                        if (disposeCancellationListener) {
                                disposeCancellationListener();
                                disposeCancellationListener = null;

I agree that a proper error message should be thrown for such scenarios since The specified icon 'extension/icon.png' wasn't found in the extension. is very misleading.

It might make sense to throw an exception when stdout is empty. (something like the patch below) Looks like all the commands are expecting some kind of response and they are having side-effects when the response is empty. What do you think @joaomoreno? I am ready to create a PR if you think it makes sense.

diff --git a/src/npm.ts b/src/npm.ts
index 71649a4..d71364e 100644
--- a/src/npm.ts
+++ b/src/npm.ts
@@ -30,6 +30,8 @@ function exec(command: string, options: IOptions = {}, cancellationToken?: Cance
                        }
 
                        if (err) { return e(err); }
+                       if (stdout === '') { return e(`'${command}' did not return any results.`); }
+
                        c({ stdout, stderr });
                });

@paleo
Copy link

paleo commented Jun 18, 2020

@xontab
I didn't understood what we have to do. Should I reinstall Node.js without snap?

EDIT: I found a practical solution. For those who have the same problem and just want to use vsce, use the node:12-alpine Docker image, execute /bin/sh in it. In the container's shell, install vsce globally (no need of sudo) and run your commands.

With docker-compose:

# docker-compose.yml
version: '3.7'
services:
  node:
    image: node:12-alpine
    volumes:
      - ".:/work"

… then run: docker-compose run node /bin/sh

In the container's shell:

npm install -g vsce
cd /work
vsce package

@xontab
Copy link
Contributor

xontab commented Jun 19, 2020

Yes, the Snap version does not support the child_process properly and thus an alternative packaging system needs to be used. Using Docker is even better :) Maybe we should build a vsce docker image to avoid these dependency issues.

@iamjameswalters
Copy link

I just encountered this issue on Ubuntu 20.04, node snap version 14.17.5 (latest stable at time of writing), while executing npx vsce publish. Has any progress been made toward a solution?

@joaomoreno
Copy link
Member

This seems more like an issue with Node's snap package than VSCE, unfortunately. Nothing we can do here, but learn the workarounds.

@gerson-henrique
Copy link

Hi guys, I managed to work around the problem by dragging my icon to the theme development git, and simply pointing the filename in "icon": "logo.png". inside the .json package

@meghasinghal1
Copy link

meghasinghal1 commented Jul 25, 2022

Hi,

Can somebody please help me in finding resolution for the above issue as I am facing same issue even with most recent version of VSCE and I saw similar issue was logged and closed. I read and tried to understand above thread but couldn't get the resolution.

image

Thanks

@true0r , @paleo , @gerson-henrique for the urgent help.

@joaomoreno
Copy link
Member

What does vsce ls return?

@meghasinghal1
Copy link

Getting this when running vsce ls command.

image

@joaomoreno
Copy link
Member

I don't see the icon listed there.

@jeff-hykin
Copy link

I hit this issue on MacOS (vsce ls always returns nothing)

npm --version          
7.1.1

node --version
v16.15.0

vsce --version
2.13.0

Changing the vsce version doesnt seem to fix anything, however downgrading node fixes the issue
This setup works:

npm --version          
7.1.1

node --version
v14.17.0

vsce --version
2.13.0

@ctjlewis
Copy link

ctjlewis commented Apr 12, 2023

Everyone who worked on the Microsoft teams that built the extensions API should not only be fired but also tried at the Hague. Seriously shameful stuff.

As someone else noted, manually verify filepaths via:

vsce ls

And use --no-dependencies if you're using pnpm.

@ssbarnea
Copy link
Contributor

@ctjlewis Frustrated? how about #858 where fix was already approved by 4 people from community but no core bothered to merge it. Open-source is hard, especially for those that have a long track of closed-source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

10 participants