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

[Bug Report] - Cannot build properly with PowerShell #602

Open
joshua-cornett opened this issue Mar 26, 2024 · 7 comments
Open

[Bug Report] - Cannot build properly with PowerShell #602

joshua-cornett opened this issue Mar 26, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@joshua-cornett
Copy link
Contributor

Describe the bug:

Build fails with config files when using PowerShell

Expected behavior:

The build should complete successfully without any errors

Actual Behavior:

The build fails after a few moments

To Reproduce:

  1. run npm start from PowerShell

Desktop (please complete the following information):

  • OS: Windows 10
  • IDE: VS Code
  • PowerShell 7.x

Possible Fix:

Ensure compatibility with PowerShell for builds in the long term.

Additional context:

The issue does not occur with WSL (Windows Subsystem for Linux), indicating an environment-specific problem.

@joshua-cornett joshua-cornett added the bug Something isn't working label Mar 26, 2024
@leekahung
Copy link
Contributor

For additional context, could you include a screenshot of the error message? Think that would be useful when debugging.

@leekahung
Copy link
Contributor

After discussion, we could potentially solve this with a new npm package that's used as a devDependency. A package like cross-env seems to be useful for cross-platform compatibility.

@DionSat
Copy link
Contributor

DionSat commented Apr 9, 2024

I'm honestly not encountering any errors for this. I run windows on my desktop and tried to run npm run start through my windows powershell and it runs fine.
image

Are you sure this is not an issue with your environment setup or PATH issue. I can't tell without the errors but since its able to build and run on my PowerShell then I don't think it's a compatibility issue.

@joshua-cornett
Copy link
Contributor Author

joshua-cornett commented Apr 10, 2024 via email

@leekahung
Copy link
Contributor

The issue seems to be related to incorrect syntax. Think we could resolve this by updating the syntax.

@joshua-cornett
Copy link
Contributor Author

joshua-cornett commented Apr 18, 2024

I believe I have a script which should handle cross-environment setup/installation. The only thing the user needs is to have node installed. I'm still testing it, but if it works, I think it'd be a nice one-size-fits-all.

If acceptable, this could reduce user setup instructions to:

  1. Install node
  2. Clone the repo with git clone https://github.com/codeforpdx/PASS.git
  3. Navigate to the cloned repo with cd PASS
  4. Run the setup script with node setup.js
#!/usr/bin/env node

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const https = require('https');

// Detect the platform
const platform = process.platform;
const isWindows = platform === 'win32';
const isMacOS = platform === 'darwin';

// Function to check if a command exists
const commandExists = (command) => {
  try {
    const cmd = isWindows ? `where ${command}` : `command -v ${command}`;
    execSync(cmd, { stdio: 'ignore' });
    return true;
  } catch (error) {
    return false;
  }
};

// Adjust install commands based on OS
const installNvm = () => {
  if (isWindows) {
    console.log('Installing nvm-windows...');
    console.log('Downloading nvm-setup.exe...');
    const file = fs.createWriteStream('nvm-setup.exe');
    const request = https.get('https://github.com/coreybutler/nvm-windows/releases/latest/download/nvm-setup.exe', function(response) {
      response.pipe(file);
      file.on('finish', function() {
        file.close(() => {
          console.log('nvm-setup.exe downloaded successfully.');
          console.log('Please run nvm-setup.exe, follow the installation instructions, and then reopen your command prompt or PowerShell to continue.');
        });
      });
    }).on('error', function(err) {
      fs.unlink('nvm-setup.exe', () => {}); // Delete the file if download fails
      console.error('Error downloading nvm-setup.exe:', err);
    });
  } else if (isMacOS) {
    console.log('Installing nvm for macOS...');
    execSync('curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash', {
      stdio: 'inherit',
      shell: true
    });
    console.log('Please reopen your terminal and run the script again.');
  } else {
    console.log('Installing nvm for Unix-like OS...');
    execSync('curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash', {
      stdio: 'inherit',
      shell: true
    });
  }
};

// Check if nvm is installed
if (!commandExists('nvm')) {
  installNvm();
} else {
  console.log('NVM is already installed.');
}

// Define commands to be executed
const commands = ['nvm install 18', 'npm install'];

// Execute commands one by one
commands.forEach((command) => {
  try {
    console.log(`Executing command: ${command}`);
    execSync(command, { stdio: 'inherit', shell: true });
  } catch (error) {
    console.error(`Error executing command: ${command}`, error);
    process.exit(1);
  }
});

// Copying environment files
const templatePath = path.join(__dirname, 'env.template');
const envPath = path.join(__dirname, '.env');
try {
  console.log('Copying environment template file...');
  fs.copyFileSync(templatePath, envPath);
  console.log('Environment template file copied successfully.');
} catch (error) {
  console.error('Error copying environment template file:', error);
  process.exit(1);
}

@joshua-cornett
Copy link
Contributor Author

For additional context, it has come to light that configuration has issues with file paths containing spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants