livace / atom-gpp Goto Github PK
View Code? Open in Web Editor NEWC++ compiler for Atom
Home Page: https://atom.io/packages/gpp
License: MIT License
C++ compiler for Atom
Home Page: https://atom.io/packages/gpp
License: MIT License
Hi
I have just installed this package and encountered this error when I pressed F9 to compile and run a file:
I'm using atom in macOS 10.15 and I have installed Xcode and its stuff.
I also tried disabling other non-core packages and restarting the atom, which didn't solve the problem.
this issue has already been reported: #9
but the user who opened the issue, closed it himself without providing any reason.
by the way, this is the full error report:
steps to reproduce:
Atom: 1.42.0 x64
Electron: 4.2.7
OS: Mac OS X 10.15.2
Thrown From: gpp package 0.4.3
Uncaught Callback must be a function
At fs.js:129
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at maybeCallback (fs.js:129:9)
at Object.writeFile (fs.js:1137:14)
at ChildProcess.child.on (/packages/gpp/index.js:57:12)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:962:16)
at Socket.stream.socket.on (internal/child_process.js:381:11)
at Socket.emit (events.js:182:13)
at Pipe._handle.close (net.js:606:12)
-6:48.6.0 core:backspace (input.hidden-input)
2x -6:43.4.0 editor:newline (input.hidden-input)
-6:38.7.0 core:backspace (input.hidden-input)
-6:36.5.0 editor:newline (input.hidden-input)
-6:34.1.0 core:backspace (input.hidden-input)
-6:31.7.0 editor:newline (input.hidden-input)
-6:30.7.0 core:backspace (input.hidden-input)
2x -6:28.6.0 editor:newline (input.hidden-input)
-6:26.8.0 core:backspace (input.hidden-input)
-6:23.9.0 gcc-make-run:compile-run (input.hidden-input)
-3:02.6.0 tree-view:remove (span.name.icon.icon-file-text)
3x -2:55.5.0 editor:newline (input.hidden-input)
-2:47.4.0 gpp-compiler:compile (input.hidden-input)
-1:54.1.0 gpp:compile-run (input.hidden-input)
atom-smart-template 0.3.2
autosave-onchange 1.5.1
gcc-make-run 0.2.12
gpp 0.4.3
gpp-compiler 3.0.7
linter-gcc 0.7.1
[Enter steps to reproduce:]
Atom: 1.34.0 x64
Electron: 3.1.1
OS: "Manjaro Linux"
Thrown From: gpp package 0.4.3
Uncaught Callback must be a function
At fs.js:157
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at maybeCallback (fs.js:157:9)
at Object.fs.writeFile (fs.js:1290:14)
at ChildProcess.child.on (/packages/gpp/index.js:57:12)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:961:16)
at Socket.stream.socket.on (internal/child_process.js:380:11)
at Socket.emit (events.js:182:13)
at Pipe._handle.close [as _onclose] (net.js:596:12)
3x -1:58 core:backspace (input.hidden-input)
-1:55.8.0 core:move-right (input.hidden-input)
-1:55.7.0 core:move-down (input.hidden-input)
2x -1:55.2.0 core:backspace (input.hidden-input)
2x -1:53.1.0 editor:newline (input.hidden-input)
6x -1:48.8.0 core:backspace (input.hidden-input)
-1:43.6.0 core:move-right (input.hidden-input)
3x -1:42.6.0 core:backspace (input.hidden-input)
11x -1:37.1.0 core:move-left (input.hidden-input)
-1:34.1.0 editor:consolidate-selections (input.hidden-input)
-1:34.1.0 core:cancel (input.hidden-input)
-1:33.3.0 core:save (input.hidden-input)
-1:31.5.0 gpp-compiler:compile (input.hidden-input)
-0:39.6.0 core:confirm (input.hidden-input)
-0:16.7.0 core:save (div.tool-panel.tree-view)
-0:05.4.0 gpp:compile-run (input.hidden-input)
atom-ide-ui 0.13.0
gpp 0.4.3
ide-python 1.2.0
python-debugger 0.2.0
I've added MinGW to the path in Windows 10 as C:\MinGW\bin
To check the install, I used the terminal:
C:\Users\mike>g++ --version
g++ (MinGW.org GCC-8.2.0-5) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\Users\mike>
In Atom, after adding the gpp-compiler package and trying to 'compile and run', I get the error:
'g++' could not be spawned. Is it installed and on your path? If so please open an issue on the package spawning the process.
Weird thing is, if I go to the project folder and enter the following, the file compiles properly and produces an executable.
**C:\Users\mike\Documents\atom\CPP>g++ main.cpp
C:\Users\mike\Documents\atom\CPP>a.exe
Hello world
C:\Users\mike\Documents\atom\CPP>**
Any fixes?
Thanks,
Mike
Hi! Thanks for maintaining the gpp package!
In Atom v1.19, we will release a major change to Atom's core text buffer data structure. As part of this change, we have made TextBuffer.save
asynchronous; rather than blocking until the save is complete, it now immediately returns a Promise
that resolves when the save is complete. Because of this, a few other Atom APIs that use save
have similarly become async:
Pane.close
TextBuffer.save
TextEditor.save
Pane.saveItem
Pane.saveItemAs
Pane.saveActiveItem
Pane.saveActiveItemAs
Pane.saveItems
Workspace.saveActivePaneItem
Workspace.saveActivePaneItemAs
We think this package could be impacted by this upgrade because it calls the changed methods in the following places:
TextEditor.save
We found these calls using a regex search, so this list might be incomplete, and it might contain some false positives.
It should be pretty easy to adjust your package code and/or tests to work with the new async behavior, and to simultaneously keep it working with older versions of Atom. Here are some examples of pull requests we opened on our bundled packages to cope with the change:
Please let me know if you have any questions. I would be happy to help!
I got an error when i wanted to compile a file with a whitespace in it's path. This is the fix for index.js:
const options = (file.path + ' -o ' + compiledPath + ' ' + atom.config.get('gpp.compilerOptions')).replace(/[\s{2,}]+/g, ' ').trim();
path.join(filePath.dir, filePath.name);
console.log(options.split(' '));
const child = child_process.spawn('g++', options.split(' '), {
cwd: filePath.dir
});
To
const options = atom.config.get('gpp.compilerOptions').replace(/[\s{2,}]+/g, ' ').trim();
path.join(filePath.dir, filePath.name);
var new_options = [file.path,'-o',compiledPath]
if (options != ""){
new_options = new_options.concat(options.split(' '));
}
const child = child_process.spawn('g++', new_options, {
cwd: filePath.dir
});
The problem was that split(' ') would split on the whitespaces in the filename.
index.js:148
let cmd = `osascript -e 'tell application "Terminal" to activate' -e 'tell application "Terminal" to do script "clear && cd ${filePath.dir} && time ./${filePath.name} && ${closeCmd} && while [ true ];do read -t 3 -n 1;if [ $? = 0 ];then exit;else continue;fi;done"'`
child_process.exec(cmd, options);
will produce a cleaner terminal and wait for enter at the end of the program to close the session and close the window instantly if you change this option in terminal preferences
[Enter steps to reproduce:]
Atom: 1.29.0 x64
Electron: 2.0.5
OS: Microsoft Windows 10 Home
Thrown From: gpp package 0.4.3
Uncaught Error: Can't save a buffer with no file
At C:\Users\Ridho\AppData\Local\atom\app-1.29.0\resources\app\node_modules\text-buffer\lib\text-buffer.js:1326
Error: Can't save a buffer with no file
at TextBuffer.module.exports.TextBuffer.saveTo (~/AppData/Local/atom/app-1.29.0/resources/app/node_modules/text-buffer/lib/text-buffer.js:1326:21)
at TextBuffer.module.exports.TextBuffer.save (~/AppData/Local/atom/app-1.29.0/resources/app/node_modules/text-buffer/lib/text-buffer.js:1310:25)
at TextEditor.save (~/AppData/Local/atom/app-1.29.0/resources/app/src/text-editor.js:1173:38)
at Object.compile (/packages/gpp/index.js:19:12)
at /packages/gpp/index.js:429:18)
at CommandRegistry.handleCommandEvent (~/AppData/Local/atom/app-1.29.0/resources/app/src/command-registry.js:384:49)
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (~/AppData/Local/atom/app-1.29.0/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (~/AppData/Local/atom/app-1.29.0/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
at WindowEventHandler.handleDocumentKeyEvent (~/AppData/Local/atom/app-1.29.0/resources/app/src/window-event-handler.js:110:40)
-8:22.4.0 editor:newline (input.hidden-input)
-8:19 core:move-right (input.hidden-input)
-8:17.2.0 editor:newline (input.hidden-input)
-8:15.8.0 snippets:next-tab-stop (input.hidden-input)
-8:15.8.0 snippets:expand (input.hidden-input)
-8:15.8.0 editor:indent (input.hidden-input)
5x -8:11.7.0 core:backspace (input.hidden-input)
-8:02.3.0 core:move-right (input.hidden-input)
-8:01.0 editor:newline (input.hidden-input)
-7:58.6.0 core:backspace (input.hidden-input)
2x -7:55.2.0 editor:newline (input.hidden-input)
5x -7:50.1.0 core:backspace (input.hidden-input)
2x -7:44.3.0 editor:newline (input.hidden-input)
3x -7:33.7.0 gpp:compile-run (input.hidden-input)
gpp 0.4.3
[Enter steps to reproduce:]
Atom: 1.31.2 x64
Electron: 2.0.7
OS: Microsoft Windows 10 Home
Thrown From: gpp package 0.4.3
Uncaught TypeError: Path must be a string. Received undefined
At path.js:28
TypeError: Path must be a string. Received undefined
at assertPath (path.js:28:11)
at Object.parse (path.js:999:5)
at Object.compile (/packages/gpp/index.js:27:27)
at /packages/gpp/index.js:429:18)
at CommandRegistry.handleCommandEvent (~/AppData/Local/atom/app-1.31.2/resources/app/src/command-registry.js:384:49)
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (~/AppData/Local/atom/app-1.31.2/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (~/AppData/Local/atom/app-1.31.2/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
at WindowEventHandler.handleDocumentKeyEvent (~/AppData/Local/atom/app-1.31.2/resources/app/src/window-event-handler.js:110:40)
gpp 0.4.3
teletype 0.13.3
atom wont install anything! it says compiler tools not found. I cant install anything on it please help mee. I dont know how to resolve this. btw my software of atom is at the latest version.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.