Adding path to PATH environment variable using bash script in /etc/environment [duplicate]

I need to add path to my executable application to PATH environment variable. Because I need to add path during .deb package installation, I should use postinst script in debian package. After reading Ubuntu official docs and Askubuntu question I decided to use /etc/environment file to add my application path due to system wide user access. Here is my bash script:

#! /bin/bash

cd ~
echo 'PATH="$PATH:/path/to/my/bin"' >> /etc/environment

and here is /etc/environment content after executing postinst bash script:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
PATH="$PATH:/path/to/my/bin"

Now when I log out and try log in, I stuck in login loop!

Update 1:

I tested the approach for .profile in Home directory and it works fine! But I need to add the path for all users so I must use /etc/environment file.


Please avoid modifing system files. Instead you should place an executable script in /etc/profile.d (scripts in here got executed for every user) to change $PATH value.

/etc/profile.d/10-<package name>.sh

#!/bin/sh
export PATH=$PATH:/path/to/executable