omnisharp-atom: Uncaught TypeError: atom.grammars.startIdForScope is not a function

Steps to reproduce:

  1. Open Atom

Atom: 1.24.0-beta1 x64 Electron: 1.6.15 OS: Microsoft Windows 10 Enterprise Thrown From: omnisharp-atom package 0.31.2

Stack Trace

Uncaught TypeError: atom.grammars.startIdForScope is not a function

At C:\Users\[username]\.atom\packages\omnisharp-atom\dist\omnisharp-atom.js:145

TypeError: atom.grammars.startIdForScope is not a function
    at grammarCb (/packages/omnisharp-atom/dist/omnisharp-atom.js:145:35)
    at Function.module.exports.Emitter.simpleDispatch (~/AppData/Local/atom/app-1.24.0-beta1/resources/app/node_modules/event-kit/lib/emitter.js:25:20)
    at Emitter.module.exports.Emitter.emit (~/AppData/Local/atom/app-1.24.0-beta1/resources/app/node_modules/event-kit/lib/emitter.js:141:34)
    at GrammarRegistry.module.exports.GrammarRegistry.addGrammar (~/AppData/Local/atom/app-1.24.0-beta1/resources/app/node_modules/first-mate/lib/grammar-registry.js:80:26)
    at Grammar.module.exports.Grammar.activate (~/AppData/Local/atom/app-1.24.0-beta1/resources/app/node_modules/first-mate/lib/grammar.js:259:54)
    at grammarRegistry.readGrammar (~/AppData/Local/atom/app-1.24.0-beta1/resources/app/src/package.js:617:53)
    at ~/AppData/Local/atom/app-1.24.0-beta1/resources/app/node_modules/first-mate/lib/grammar-registry.js:126:61
    at parseContents (~/AppData/Local/atom/app-1.24.0-beta1/resources/app/node_modules/season/lib/cson.js:123:13)
    at ~/AppData/Local/atom/app-1.24.0-beta1/resources/app/node_modules/season/lib/cson.js:230:26
    at ELECTRON_ASAR.js:498:9
    at FSReqWrap.wrapper [as oncomplete] (fs.js:603:17)

Non-Core Packages

atom-ide-ui 0.7.0 
atom-material-syntax 1.0.8 
atom-material-ui 2.0.6 
autocomplete-paths 2.12.1 
busy-signal 1.4.3 
editorconfig 2.2.2 
emmet 2.4.3 
file-icons 2.1.15 
flatwhite-syntax 0.8.1 
flow-ide 1.9.0 
github-atom-light-syntax 0.5.0 
hyperclick 0.0.0 
ide-typescript 0.7.2 
intentions 1.1.5 
language-babel 2.81.1 
language-cshtml 0.3.0 
language-elm 1.5.0 
language-vue 0.23.1 
linter 2.2.0 
linter-eslint 8.4.0 
linter-ui-default 1.6.10 
markdown-writer 2.7.3 
monokai 0.24.0 
nova-atom-syntax 1.5.0 
nova-atom-ui 1.3.0 
oceanic-next 1.0.0 
omnisharp-atom 0.31.2 
prettier-atom 0.43.1 
react 0.17.0 
sync-settings 0.8.3 

About this issue

Most upvoted comments

@theslyprofessor I might be a little late, but I have gotten it to work by finding the file omnisharp-atom.js. It’s located in the your-username/.atom/packages/omnisharp-atom/dist folder. If you don’t find it there, try letting explorer search for omnisharp-atom.js in the whole drive, and it should find it …

Anyway, find it and open it in a text editor, then search for “var grammars = atom.grammars;”. This will take you to line 140. Replace that whole line with “var grammars = atom.grammars.textmateRegistry || atom.grammars;”.

Then you shall move on to line 145, “atom.grammars.startIdForScope(grammar.scopeName);” and replace it with “grammars.startIdForScope(grammar.scopeName);”. Then you save the file and relaunch Atom. Good luck and hope it works now!

Same on released production version 1.24 on Mac OS X:

[Enter steps to reproduce:]

  1. Start Atom
  2. Get big red bug alert

Atom: 1.24.0 x64 Electron: 1.6.16 OS: Mac OS X 10.13.3 Thrown From: omnisharp-atom package 0.31.2

Stack Trace

Uncaught TypeError: atom.grammars.startIdForScope is not a function

At ~/.atom/packages/omnisharp-atom/dist/omnisharp-atom.js:145

TypeError: atom.grammars.startIdForScope is not a function
    at grammarCb (/packages/omnisharp-atom/dist/omnisharp-atom.js:145:35)
    at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:20)
    at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:34)
    at GrammarRegistry.module.exports.GrammarRegistry.addGrammar (/Applications/Atom.app/Contents/Resources/app/node_modules/first-mate/lib/grammar-registry.js:80:26)
    at Grammar.module.exports.Grammar.activate (/Applications/Atom.app/Contents/Resources/app/node_modules/first-mate/lib/grammar.js:259:54)
    at grammarRegistry.readGrammar (/Applications/Atom.app/Contents/Resources/app/src/package.js:617:53)
    at /Applications/Atom.app/Contents/Resources/app/node_modules/first-mate/lib/grammar-registry.js:126:61
    at parseContents (/Applications/Atom.app/Contents/Resources/app/node_modules/season/lib/cson.js:123:13)
    at /Applications/Atom.app/Contents/Resources/app/node_modules/season/lib/cson.js:230:26
    at ELECTRON_ASAR.js:498:9
    at FSReqWrap.wrapper [as oncomplete] (fs.js:603:17)

Commands

Non-Core Packages

angular-2-typeScript-snippets 0.7.0 
angular2-snippets 0.4.0 
atom-ide-ui 0.8.1 
atom-material-syntax-light 0.4.6 
atom-material-ui 2.1.1 
atom-typescript 12.1.2 
atom-yii2 0.4.0 
autocomplete-clang 0.11.4 
build 0.70.0 
busy-signal 1.4.3 
docblockr 0.13.6 
editorconfig 2.2.2 
file-icons 2.1.16 
hyperclick 0.0.0 
ide-csharp 0.6.1 
ide-json 0.2.0 
ide-php 0.7.5 
ide-python 0.7.0 
intentions 1.1.5 
language-ini 1.19.0 
language-matlab 0.2.1 
linter 2.2.0 
linter-eslint 8.4.1 
linter-gcc 0.7.1 
linter-php 1.5.1 
linter-tidy 2.3.1 
linter-tslint 1.9.0 
linter-ui-default 1.6.10 
nativescript-ng2-atom-snippets 1.2.0 
omnisharp-atom 0.31.2 
php-composer-completion 0.3.4 
php-cs-fixer 4.1.1 
php-integrator-annotations 1.2.0 
php-integrator-autocomplete-plus 1.6.2 
php-integrator-base 3.2.1 
php-integrator-refactoring 1.4.1 
platformio-ide-debugger 1.2.5 
platformio-ide-terminal 2.8.0 
prettier-atom undefined 
project-manager 3.3.5 
symbols-tree-view 0.14.0 
tool-bar 1.1.6 
webbox-color 0.5.9 

@koxu1996 's solution is really close

The startIdForScope call references atom.grammars directly, so you need to switch it to just grammars as well.

Simple solution

Replace 140 line of omnisharp-atom.js from: var grammars = atom.grammars; to var grammars = atom.grammars.textmateRegistry || atom.grammars;

Not meaning to be rude, but just wondering if this project has been dropped in favour of https://github.com/OmniSharp/omnisharp-vscode, as there hasn’t been a commit here in over 10 months, and issues don’t seem to be getting addressed?

I’d be possibly interested in helping move it from DNVM to DotNet CLI, which seems to be the cause of the latest build fail, but not if it’s being deprecated.