Do you want to request a _feature_ or report a _bug_?
Bug.
What is the current behavior?
I get an error while using yarn install instead of just ignoring the dependency.
If the current behavior is a bug, please provide the steps to reproduce.
Here is an excerpt of my package.json:
{
// ...
"dependencies": {
// ...
},
"devDependencies": {
// ...
},
"optionalDependencies": {
"appdmg": "^0.4.5",
// ...
},
// ...
}
Then :
yarn install
Result:
yarn install v0.16.1
info No lockfile found.
warning [email protected]: No license field
[1/4] Resolving packages...
warning electron-prebuilt > electron-download > nugget > progress-stream > through2 > xtend > [email protected]:
[2/4] Fetching packages...
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
error [email protected]: The platform "linux" is incompatible with this module.
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
_As a comment, it is important to underline that appdmg has actually a dependency named ds-store that has one named macos-alias._
What is the expected behavior?
Yarn should completely ignore appdmg, therefore any dependency related to it.
Please mention your node.js, yarn and operating system version.
Node: 6.5.0
OS: Linux Ubuntu 16.04 (work on OSX 10.10.5 since appdmg is for Darwin).
I actually see two solutions to that issue. (I did two commit, preferring the second solution, I did a pull request)
In the file src/package-request.js, find():
Solution 1: Simply mark all dependencies of an optionalDependency as optional.
https://github.com/pierrefourgeaud/yarn/commit/f6f159d63b5dfc1b854d5c479d07d6d08e2381b4
Solution 2: Check if the optional dependency works with the os, if it doesn't just pass it.
https://github.com/pierrefourgeaud/yarn/commit/6e6b613cb592d861e28fd07744252bc780536080
https://github.com/yarnpkg/yarn/pull/1438
This is still an issue, the fix provided by @mvestergaard doesn't affect this one. Here is a screenshot of my last try:

I think that is caused by the same as #2142
I think I've figured out a way around this
yarn install --ignore-platform seems to do the trick for me though I am unsure if there will be any side effects from using that.
This is a big problem for Electron apps, it means that any yarn.lock you generate is probably wrong and only works on that platform /cc https://github.com/zeit/hyper/pull/1360
Most helpful comment
This is a big problem for Electron apps, it means that any
yarn.lockyou generate is probably wrong and only works on that platform /cc https://github.com/zeit/hyper/pull/1360