Skip to content

Commit e46abf2

Browse files
michael-borckclaude
andcommitted
Fix Linux AppImage userData path creation errors
- Improve production mode detection using process.resourcesPath - Prevent directory creation inside read-only AppImage filesystem - Only create userData directories in development mode - AppImage now runs without --no-sandbox requirement for userData 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d60e7d4 commit e46abf2

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

main.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Add command line arguments for development BEFORE requiring electron
2-
const isDev = process.env.NODE_ENV !== 'production';
2+
const isDev = process.env.NODE_ENV !== 'production' && !process.resourcesPath;
33

44
// Import electron
55
const { app, BrowserWindow } = require('electron');
@@ -29,21 +29,27 @@ if (isDev) {
2929
console.log('📁 Using production userData path:', userDataPath);
3030
}
3131

32-
// Ensure the directory exists
33-
if (!fs.existsSync(userDataPath)) {
34-
console.log('📂 Creating userData directory:', userDataPath);
35-
fs.mkdirSync(userDataPath, { recursive: true });
36-
console.log('✅ userData directory created');
32+
// Ensure the directory exists (only in development mode)
33+
if (isDev) {
34+
if (!fs.existsSync(userDataPath)) {
35+
console.log('📂 Creating dev userData directory:', userDataPath);
36+
fs.mkdirSync(userDataPath, { recursive: true });
37+
console.log('✅ Dev userData directory created');
38+
} else {
39+
console.log('📂 Dev userData directory already exists');
40+
}
3741
} else {
38-
console.log('📂 userData directory already exists');
42+
console.log('📂 Using production userData path (Electron will handle creation):', userDataPath);
3943
}
4044

41-
// List what's in the directory
42-
try {
43-
const files = fs.readdirSync(userDataPath);
44-
console.log('📁 Contents of userData directory:', files);
45-
} catch (e) {
46-
console.log('📁 Could not read userData directory contents:', e.message);
45+
// List what's in the directory (development only)
46+
if (isDev) {
47+
try {
48+
const files = fs.readdirSync(userDataPath);
49+
console.log('📁 Contents of dev userData directory:', files);
50+
} catch (e) {
51+
console.log('📁 Could not read dev userData directory contents:', e.message);
52+
}
4753
}
4854

4955
// Initialize Next.js

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "study-buddy",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "An open-source AI personal tutor that runs locally on your computer",
55
"author": {
66
"name": "Study Buddy Contributors",

0 commit comments

Comments
 (0)