remotion icon indicating copy to clipboard operation
remotion copied to clipboard

npm start error: No available ports found on windows wsl

Open jifffffy opened this issue 1 year ago • 6 comments

Error: No available ports found when I run npm start.

Bug Report 🐛

I follow the office doc to create a test project as follows:

# install deps
sudo apt install -y \
  libnss3 \
  libdbus-1-3 \
  libatk1.0-0 \
  libasound2t64 \  # libasound2 not exist refs https://github.com/cypress-io/cypress-documentation/issues/5816
  libxrandr2 \
  libxkbcommon-dev \
  libxfixes3 \
  libxcomposite1 \
  libxdamage1 \
  libgbm-dev \
  libatk-bridge2.0-0
 # create a project
npx create-video@latest

but i got an error when I run npm start: image

other infomation: os: ubuntu 24.04 remotion: 4.0.212

jifffffy avatar Sep 18 '24 11:09 jifffffy

Are you able to bind to any port between 3000 and 3001 with other frameworks? Can you create a Next or Vite project for example?

JonnyBurger avatar Sep 18 '24 11:09 JonnyBurger

yes, I am sure no ohter process bind port 3000 and 3001, it is ok when I run on the windows and mac. this is not the first my remotion project, but this is the first in the wsl. I reboot the computer. but I still get the error. thanks very much your quickly replay!

jifffffy avatar Sep 18 '24 12:09 jifffffy

in get-port.ts file using the host addrest 127.0.0.1 and 0.0.0.0. cause that socket connect timeout 127.0.0.1 and 0.0.0.0 in wsl cannot access with any port. should use a real ip address. if I remove the ipv4 address, everything is ok. image

jifffffy avatar Sep 20 '24 05:09 jifffffy

Thanks for investigating - What is a real IP address then? If localhost is not available?

JonnyBurger avatar Sep 20 '24 06:09 JonnyBurger

Maybe we should copy the logic from Vite

https://github.com/vitejs/vite/blob/21ec1ce7f041efa5cd781924f7bc536ab406a197/packages/vite/src/node/utils.ts#L933

JonnyBurger avatar Sep 20 '24 06:09 JonnyBurger

The real address can get in the wsl as follows:

ip route show | grep -i default | awk '{ print $3}'

so it is good passing as a flag to the cli.

jifffffy avatar Sep 20 '24 07:09 jifffffy

I am having a hard time getting WSL2 to run on my Windows for some reason.

Is somebody able to improve the logic in get-port.ts? https://github.com/remotion-dev/remotion/blob/main/packages/renderer/src/get-port.ts

Must be able to test it on WSL2! Ideally it should not spawn a child process, surely there is a better way?

Bounty

💎 This issue has a bounty on it!

Read our contributing guidelines:

  • How to contribute: https://www.remotion.dev/docs/contributing/
  • Implementing a new feature: https://www.remotion.dev/docs/contributing/feature
  • Implementing a new option: https://www.remotion.dev/docs/contributing/option
  • Write documentation: https://www.remotion.dev/docs/contributing/docs
  • Bounty information: https://www.remotion.dev/docs/contributing/bounty

/bounty 150

JonnyBurger avatar Nov 28 '24 09:11 JonnyBurger

💎 $150 bounty • Remotion

~~## 💎 $150 bounty • Remotion~~

Steps to solve:

  1. Get assigned: If you'd like to work on this issue, comment /attempt #4315 below to get assigned
  2. Submit work: Create a pull request including /claim #4315 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to remotion-dev/remotion!

Add a bountyShare on socials

algora-pbc[bot] avatar Nov 28 '24 09:11 algora-pbc[bot]

@JonnyBurger can I get assigned?

/attempt #4315

Algora profile Completed bounties Tech Active attempts Options
@hunxjunedo    4 remotion bounties
+ 12 bounties from 4 projects
TypeScript, JavaScript,
MDX
Cancel attempt

hunxjunedo avatar Nov 28 '24 09:11 hunxjunedo

@hunxjunedo: The Remotion team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started.

algora-pbc[bot] avatar Nov 28 '24 09:11 algora-pbc[bot]

No more attempts

This issue has been assigned to @hunxjunedo 🎉

Do not send pull requests for this issue, do not ask to be in the queue, do not bother the assignee.
We will not accept any PRs not from the assignee and not award any bounties.

Follow the #bounties channel on the Remotion Discord to get notified of new bounties.@hunxjunedo There you go!

JonnyBurger avatar Nov 28 '24 09:11 JonnyBurger

@JonnyBurger its working fine on my end, @jifffffy can you provide more details so I can reproduce ? Are you using WSL 2 ? Because it seems to be working fine on WSL 2. Can you provide detailed steps to reproduce ?

Image

hunxjunedo avatar Nov 29 '24 18:11 hunxjunedo

@hunxjunedo I'm terribly sorry for the late reply. the problem exists. I've created a brand-new environment for testing today. I install system deps first:

apt install -y \
  libnss3 \
  libdbus-1-3 \
  libatk1.0-0 \
  libasound2t64 \
  libxrandr2 \
  libxkbcommon-dev \
  libxfixes3 \
  libxcomposite1 \
  libxdamage1 \
  libgbm-dev \
  libatk-bridge2.0-0

then I create a test project with the code-hike template

npx create-video@latest 

then I ensure Headless Shell is available, It might be optional.

npx remotion browser ensure

last I upgrade remotion to the latest version

npx remotion upgrade

now the package.json shows:

  "dependencies": {
    "@code-hike/lighter": "0.9.4",
    "@remotion/cli": "4.0.234",
    "@remotion/google-fonts": "4.0.234",
    "@remotion/layout-utils": "4.0.234",
    "@remotion/studio": "4.0.234",
    "codehike": "1.0.4",
    "polished": "4.3.1",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "remotion": "4.0.234",
    "twoslash-cdn": "0.2.9",
    "zod": "3.22.3"
  },

but when I run npm run dev, the error exist. Image

this is my test project this is my wsl version Image os version Image

jifffffy avatar Dec 05 '24 03:12 jifffffy

if hostsToTest changes to hostsToTest.slice(0,1) will be ok as I said before.

const getPort = async ({ from, to, hostsToTest, }) => {
    const ports = makeRange(from, to);
    for (const port of ports) {
        if ((await (0, exports.testPortAvailableOnMultipleHosts)({
            port,
            hosts: hostsToTest.slice(0,1),
        })) === 'available') {
            return port;
        }
    }
    throw new Error('No available ports found');
};

Image

jifffffy avatar Dec 05 '24 03:12 jifffffy

hey @jifffffy , I've tried to reproduce the issue many ways, even with the steps you mentioned, but still everything works fine:

Image Image

now if you ask me, I'm solid sure that there's something wrong with your wsl installation, what made me think that is the screenshot you shared in which you invoke wsl --version and it responds; there is no official version of wsl that accepts such paramter, rather it should not recognize --version. Can you please look into it ? And ensure you install wsl from the official source, like thru Ubuntu wsl on MS Store.

hunxjunedo avatar Dec 05 '24 11:12 hunxjunedo

Thank you very much for your replay. I've found the soulation. the problem is my wsl config. I had this .wslconfig file in my home dir:

[wsl2]
networkingMode=mirrored

I removed it and shutdown wsl. Now, everythind is ok. Thanks again. PS: WSL commands has --version flag.

jifffffy avatar Dec 06 '24 01:12 jifffffy

/tip $150 @hunxjunedo

JonnyBurger avatar Dec 06 '24 11:12 JonnyBurger

🎉🎈 @hunxjunedo has been awarded $150! 🎈🎊

algora-pbc[bot] avatar Dec 06 '24 11:12 algora-pbc[bot]